-
Notifications
You must be signed in to change notification settings - Fork 172
Simple interactive shell added #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 10 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
fe12363
#145 Simple interactive shell added
EvilFreelancer a063b7f
#145 linter
EvilFreelancer cf5f947
#145 Conflicts solved
EvilFreelancer 5f94683
#145 argsparse
EvilFreelancer 5fdcfa2
#145 CLI keyboard interaption logic added
EvilFreelancer ecb489f
#145 DialogAgent added
EvilFreelancer 7b6cea3
#145 Tunes of sgrsh loop
EvilFreelancer e052b9d
#145 sgrsh stabilization
EvilFreelancer 76f2ca4
#145 linter
EvilFreelancer 3625951
#145 linter
EvilFreelancer dbcc570
Update sgr_agent_core/cli/sgrsh.py
EvilFreelancer 2be8ac9
Update sgr_agent_core/cli/sgrsh.py
EvilFreelancer 9fbdcb6
Merge branch 'main' into 145-sgrsh
EvilFreelancer 3f52ceb
#145 pydantic cli
EvilFreelancer 9a8c18a
#145 Small fix of comment
EvilFreelancer be8c6e1
#145 Multistep logic moved from base agent to dialog, e2e tests desel…
EvilFreelancer c651d66
#145 Simplification of sgrsh logic
EvilFreelancer 2395958
#145 typo fixed
EvilFreelancer 2d6426a
#145 cleanup
EvilFreelancer 3e7afbc
Merge branch 'main' into 145-sgrsh
EvilFreelancer af9eff4
#145 conflict solved
EvilFreelancer 75b172d
#145 linter
EvilFreelancer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,52 @@ | ||
| """Dialog agent for long-running conversations with intermediate results.""" | ||
|
|
||
| from typing import Type | ||
|
|
||
| from openai import AsyncOpenAI | ||
|
|
||
| from sgr_agent_core.agent_definition import AgentConfig | ||
| from sgr_agent_core.agents.sgr_tool_calling_agent import SGRToolCallingAgent | ||
| from sgr_agent_core.models import AgentStatesEnum | ||
| from sgr_agent_core.tools import AnswerTool, BaseTool | ||
|
|
||
|
|
||
| class DialogAgent(SGRToolCallingAgent): | ||
| """Agent specialized for dialog interactions with intermediate results. | ||
|
|
||
| Uses AnswerTool to share intermediate results and maintain | ||
| conversation flow, keeping the agent available for further | ||
| interactions. Supports long dialogs with full conversation history. | ||
| """ | ||
|
|
||
| name: str = "dialog_agent" | ||
|
|
||
| def __init__( | ||
| self, | ||
| task_messages: list, | ||
| openai_client: AsyncOpenAI, | ||
| agent_config: AgentConfig, | ||
| toolkit: list[Type[BaseTool]], | ||
| def_name: str | None = None, | ||
| **kwargs: dict, | ||
| ): | ||
| # Ensure AnswerTool is in toolkit for dialog flow; keep tools from config/registry | ||
| answer_toolkit = [AnswerTool] | ||
| merged_toolkit = answer_toolkit + [t for t in toolkit if t is not AnswerTool] | ||
| super().__init__( | ||
| task_messages=task_messages, | ||
| openai_client=openai_client, | ||
| agent_config=agent_config, | ||
| toolkit=merged_toolkit, | ||
| def_name=def_name, | ||
| **kwargs, | ||
| ) | ||
|
|
||
| async def _after_action_phase(self, action_tool: BaseTool, result: str) -> None: | ||
| """Wait for user response when AnswerTool was used.""" | ||
| await super()._after_action_phase(action_tool, result) | ||
| if isinstance(action_tool, AnswerTool): | ||
| self.logger.info("\n💬 Dialog shared - agent waiting for response") | ||
| self._context.state = AgentStatesEnum.WAITING_FOR_CLARIFICATION | ||
| self.streaming_generator.finish(result) | ||
| self._context.clarification_received.clear() | ||
| await self._context.clarification_received.wait() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.