-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #880 from cheshire-cat-ai/develop
1.7.1
- Loading branch information
Showing
49 changed files
with
634 additions
and
965 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .base_agent import BaseAgent, AgentOutput | ||
|
||
__all__ = ['BaseAgent', 'AgentOutput'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import traceback | ||
from cat.experimental.form import CatFormState | ||
from cat.agents import BaseAgent, AgentOutput | ||
from cat.log import log | ||
|
||
class FormAgent(BaseAgent): | ||
|
||
async def execute(self, stray) -> AgentOutput: | ||
|
||
# get active form from working memory | ||
active_form = stray.working_memory.active_form | ||
|
||
if not active_form: | ||
# no active form | ||
return AgentOutput() | ||
elif active_form._state == CatFormState.CLOSED: | ||
# form is closed, delete it from working memory | ||
stray.working_memory.active_form = None | ||
return AgentOutput() | ||
else: | ||
# continue form | ||
try: | ||
form_output = active_form.next() # form should be async and should be awaited | ||
return AgentOutput( | ||
output=form_output["output"], | ||
return_direct=True, # we assume forms always do a return_direct | ||
intermediate_steps=[ | ||
((active_form.name, ""), form_output["output"]) | ||
] | ||
) | ||
|
||
except Exception as e: | ||
log.error(e) | ||
traceback.print_exc() | ||
return AgentOutput() | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.