Skip to content

Commit

Permalink
fix cheshire-cat-ai#879; more flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
pieroit committed Aug 7, 2024
1 parent 0fad762 commit 2359fdb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/cat/agents/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .base_agent import BaseAgent, AgentOutput
4 changes: 3 additions & 1 deletion core/cat/agents/main_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ async def execute(self, stray) -> AgentOutput:
fast_reply = self.mad_hatter.execute_hook(
"agent_fast_reply", fast_reply, cat=stray
)
if len(fast_reply.keys()) > 0:
if isinstance(fast_reply, AgentOutput):
return fast_reply
if isinstance(fast_reply, dict) and "output" in fast_reply:
return AgentOutput(**fast_reply)

# obtain prompt parts from plugins
prompt_prefix = self.mad_hatter.execute_hook(
Expand Down
2 changes: 2 additions & 0 deletions core/cat/looking_glass/stray_cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,9 @@ async def __call__(self, message_dict):

# why this response?
why = self.__build_why()
# TODO: should these assignations be included in self.__build_why ?
why.intermediate_steps = agent_output.intermediate_steps
why.agent_output = agent_output.model_dump()

# prepare final cat message
final_output = CatMessage(
Expand Down

0 comments on commit 2359fdb

Please sign in to comment.