Skip to content

Commit

Permalink
fix: update brain.py and CodeInterpreterIntermediateResult
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu007 committed Sep 2, 2024
1 parent 6455ce8 commit 5c7eeec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/codeinterpreterapi/brain/brain.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ def run(
self.update_agent_score()
if isinstance(output, str):
output = CodeInterpreterIntermediateResult(context=output)
elif not isinstance(output, CodeInterpreterIntermediateResult):
output = CodeInterpreterIntermediateResult(context=str(output))
return output

def _set_output_llm_result(
Expand Down
11 changes: 11 additions & 0 deletions src/codeinterpreterapi/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ class CodeInterpreterIntermediateResult(BaseModel):
iteration_count: int = Field(default=0, description="現在の反復回数")
max_iterations: int = Field(default=10, description="最大反復回数")

def __str__(self) -> str:
return self.__repr__()

def __repr__(self) -> str:
return f"""CodeInterpreterIntermediateResult(
thoughts={self.thoughts},
context={self.context},
code={self.code},
log={self.log}
confidence={self.confidence})"""


class CodeInterpreterResponse(AIMessage):
"""
Expand Down

0 comments on commit 5c7eeec

Please sign in to comment.