Skip to content

Commit

Permalink
style: format code with Autopep8
Browse files Browse the repository at this point in the history
This commit fixes the style issues introduced in 1ba3e08 according to the output
from Autopep8.

Details: None
  • Loading branch information
deepsource-autofix[bot] authored Dec 19, 2024
1 parent 1ba3e08 commit 763a6b8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions python/openwebui/pipe_mcts.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@

# =============================================================================


class AsyncIteratorCallbackHandler(AsyncCallbackHandler):
def __init__(self):
self.queue = asyncio.Queue()
Expand All @@ -86,6 +87,7 @@ async def __aiter__(self):
break
yield token


class LLMClient:
def __init__(self, valves: "Pipe.Valves"):
self.openai_api_key = valves.OPENAI_API_KEY
Expand Down Expand Up @@ -182,12 +184,14 @@ def get_chunk_content(self, chunk):
if "content" in delta:
yield delta["content"]
except json.JSONDecodeError:
logger.error(f'ChunkDecodeError: unable to parse "{chunk_str[:100]}"')
logger.error(
f'ChunkDecodeError: unable to parse "{chunk_str[:100]}"')

# =============================================================================

# MCTS Classes


class Node:
def __init__(
self,
Expand Down Expand Up @@ -240,6 +244,7 @@ def mermaid(self, offset=0, selected=None):
logger.debug(f"Node Mermaid:\n{msg}")
return msg


class MCTSAgent:
def __init__(
self,
Expand Down Expand Up @@ -434,7 +439,8 @@ async def update_approach(self, answer: str, improvements: str):
return await self.generate_completion(prompt)

async def evaluate_answer(self, answer: str):
prompt = eval_answer_prompt.format(question=self.question, answer=answer)
prompt = eval_answer_prompt.format(
question=self.question, answer=answer)
result = await self.generate_completion(prompt)
try:
score = int(re.search(r"\d+", result).group())
Expand Down Expand Up @@ -487,6 +493,7 @@ async def emit_replace(self, content: str):

# Prompts


thoughts_prompt = """
<instruction>
Give a suggestion on how this answer can be improved.
Expand Down Expand Up @@ -658,7 +665,8 @@ async def pipe(
if match:
backend, model_name = match.groups()
else:
logger.error("Model ID should be in the format '*.mcts/backend/model_name'")
logger.error(
"Model ID should be in the format '*.mcts/backend/model_name'")
logger.error(f"Invalid model ID: {model_id}")
return ""

Expand Down

0 comments on commit 763a6b8

Please sign in to comment.