-
Notifications
You must be signed in to change notification settings - Fork 172
Hybrid agents #18
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
Merged
Hybrid agents #18
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
f9d6fb4
Refactor agent structure and add tool-calling agents
virrius 78926b1
Refactor agent and tool architecture, remove legacy schemas
virrius 58d7eb4
agent class docstrings
virrius 3a26e69
Rename ResearchCompletionTool to CompletionTool
virrius 2cf7b85
Refactor agent architecture and tool handling
virrius 190c664
Update sgr_tools_agent.py
virrius 40008c3
Refactor agent imports and update __init__ modules
virrius 12328f7
Add agent model selection and model listing endpoint
virrius 6db5030
Remove debug print from agent state loop
virrius 5e1b227
linting fixes
virrius 94149ba
Add SGRSOToolCallingResearchAgent
virrius 279569f
Update sgr_so_tools_agent.py
virrius a041fdc
Update Docker volumes and remove agent test code
virrius f66f5cf
Update docstrings and agent ID naming for clarity
virrius 1d3803d
Rename agent.py to base_agent.py and update imports
virrius ff6ab7e
Update sgr_deep_research/api/models.py
virrius 9296545
Update sgr_deep_research/core/agents/tools_agent.py
virrius f1b9559
Update sgr_deep_research/core/agents/base_agent.py
virrius 90fed3e
Translate comments and fields to English
virrius 72f7b37
Refactor tool imports for consistency and clarity
virrius abbdcc1
Update endpoints.py
virrius 3a0f9a8
Update model name in README examples
virrius edd8d00
Update docker-compose.yml
virrius 6d64224
Note about /models added
EvilFreelancer 8f22ec9
Table of agents added
EvilFreelancer 96648c2
Tunes
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
virrius marked this conversation as resolved.
Show resolved
Hide resolved
|
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 |
|---|---|---|
| @@ -1,69 +1,100 @@ | ||
| """OpenAI-совместимые модели для API endpoints.""" | ||
| """OpenAI-compatible models for API endpoints.""" | ||
|
|
||
| from enum import Enum | ||
| from typing import Any, Dict, List, Literal | ||
|
|
||
| from pydantic import BaseModel, Field | ||
|
|
||
| from sgr_deep_research.core.agents import ( | ||
| SGRAutoToolCallingResearchAgent, | ||
| SGRResearchAgent, | ||
| SGRSOToolCallingResearchAgent, | ||
| SGRToolCallingResearchAgent, | ||
| ToolCallingResearchAgent, | ||
| ) | ||
|
|
||
|
|
||
| class AgentModel(str, Enum): | ||
| """Available agent models for chat completion.""" | ||
|
|
||
| SGR_AGENT = "sgr-agent" | ||
| SGR_TOOLS_AGENT = "sgr-tools-agent" | ||
| SGR_AUTO_TOOLS_AGENT = "sgr-auto-tools-agent" | ||
| SGR_SO_TOOLS_AGENT = "sgr-so-tools-agent" | ||
| TOOLS_AGENT = "tools-agent" | ||
|
|
||
|
|
||
| # Mapping of agent types to their classes | ||
| AGENT_MODEL_MAPPING = { | ||
| AgentModel.SGR_AGENT: SGRResearchAgent, | ||
| AgentModel.SGR_TOOLS_AGENT: SGRToolCallingResearchAgent, | ||
| AgentModel.SGR_AUTO_TOOLS_AGENT: SGRAutoToolCallingResearchAgent, | ||
| AgentModel.SGR_SO_TOOLS_AGENT: SGRSOToolCallingResearchAgent, | ||
| AgentModel.TOOLS_AGENT: ToolCallingResearchAgent, | ||
| } | ||
|
|
||
|
|
||
| class ChatMessage(BaseModel): | ||
| """Сообщение в чате.""" | ||
| """Chat message.""" | ||
|
|
||
| role: Literal["system", "user", "assistant", "tool"] = Field(default="user", description="Роль отправителя") | ||
| content: str = Field(description="Содержимое сообщения") | ||
| role: Literal["system", "user", "assistant", "tool"] = Field(default="user", description="Sender role") | ||
| content: str = Field(description="Message content") | ||
|
|
||
|
|
||
| class ChatCompletionRequest(BaseModel): | ||
| """Запрос на создание chat completion.""" | ||
| """Request for creating chat completion.""" | ||
|
|
||
| model: str | None = Field( | ||
| default=None, description="Идентификатор агента", example="sgr_agent_35702b10-4d4e-426f-9b33-b170032e37df" | ||
| default=AgentModel.SGR_AGENT, | ||
| description="Agent type or existing agent identifier", | ||
| example="sgr-agent", | ||
| ) | ||
| messages: List[ChatMessage] = Field(description="Список сообщений") | ||
| stream: bool = Field(default=True, description="Включить потоковый режим") | ||
| max_tokens: int | None = Field(default=1500, description="Максимальное количество токенов") | ||
| temperature: float | None = Field(default=0, description="Температура генерации") | ||
| messages: List[ChatMessage] = Field(description="List of messages") | ||
| stream: bool = Field(default=True, description="Enable streaming mode") | ||
| max_tokens: int | None = Field(default=1500, description="Maximum number of tokens") | ||
| temperature: float | None = Field(default=0, description="Generation temperature") | ||
|
|
||
|
|
||
| class ChatCompletionChoice(BaseModel): | ||
| """Выбор в ответе chat completion.""" | ||
| """Choice in chat completion response.""" | ||
|
|
||
| index: int = Field(description="Индекс выбора") | ||
| message: ChatMessage = Field(description="Сообщение ответа") | ||
| finish_reason: str | None = Field(description="Причина завершения") | ||
| index: int = Field(description="Choice index") | ||
| message: ChatMessage = Field(description="Response message") | ||
| finish_reason: str | None = Field(description="Finish reason") | ||
|
|
||
|
|
||
| class ChatCompletionResponse(BaseModel): | ||
| """Ответ chat completion (не потоковый).""" | ||
| """Chat completion response (non-streaming).""" | ||
|
|
||
| id: str = Field(description="ID ответа") | ||
| id: str = Field(description="Response ID") | ||
| object: Literal["chat.completion"] = "chat.completion" | ||
| created: int = Field(description="Время создания") | ||
| model: str = Field(description="Использованная модель") | ||
| choices: List[ChatCompletionChoice] = Field(description="Список выборов") | ||
| usage: Dict[str, int] | None = Field(default=None, description="Информация об использовании") | ||
| created: int = Field(description="Creation time") | ||
| model: str = Field(description="Model used") | ||
| choices: List[ChatCompletionChoice] = Field(description="List of choices") | ||
| usage: Dict[str, int] | None = Field(default=None, description="Usage information") | ||
|
|
||
|
|
||
| class HealthResponse(BaseModel): | ||
| status: Literal["healthy"] = "healthy" | ||
| service: str = Field(default="SGR Deep Research API", description="Название сервиса") | ||
| service: str = Field(default="SGR Deep Research API", description="Service name") | ||
|
|
||
|
|
||
| class AgentStateResponse(BaseModel): | ||
| agent_id: str = Field(description="ID агента") | ||
| task: str = Field(description="Задача агента") | ||
| state: str = Field(description="Текущее состояние агента") | ||
| searches_used: int = Field(description="Количество выполненных поисков") | ||
| clarifications_used: int = Field(description="Количество запрошенных уточнений") | ||
| sources_count: int = Field(description="Количество найденных источников") | ||
| current_state: Dict[str, Any] | None = Field(default=None, description="Текущий шаг агента") | ||
| agent_id: str = Field(description="Agent ID") | ||
| task: str = Field(description="Agent task") | ||
| state: str = Field(description="Current agent state") | ||
| searches_used: int = Field(description="Number of searches performed") | ||
| clarifications_used: int = Field(description="Number of clarifications requested") | ||
| sources_count: int = Field(description="Number of sources found") | ||
| current_state: Dict[str, Any] | None = Field(default=None, description="Current agent step") | ||
|
|
||
|
|
||
| class AgentListItem(BaseModel): | ||
| agent_id: str = Field(description="ID агента") | ||
| task: str = Field(description="Задача агента") | ||
| state: str = Field(description="Текущее состояние агента") | ||
| agent_id: str = Field(description="Agent ID") | ||
| task: str = Field(description="Agent task") | ||
| state: str = Field(description="Current agent state") | ||
|
|
||
|
|
||
| class AgentListResponse(BaseModel): | ||
| agents: List[AgentListItem] = Field(description="Список агентов") | ||
| total: int = Field(description="Общее количество агентов") | ||
| agents: List[AgentListItem] = Field(description="List of agents") | ||
| total: int = Field(description="Total number of agents") |
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 |
|---|---|---|
| @@ -1,18 +1,32 @@ | ||
| """Core modules for SGR Deep Research.""" | ||
|
|
||
| from sgr_deep_research.core.agent import SGRResearchAgent | ||
| from sgr_deep_research.core.agents import ( # noqa: F403 | ||
| BaseAgent, | ||
| SGRAutoToolCallingResearchAgent, | ||
| SGRResearchAgent, | ||
| SGRSOToolCallingResearchAgent, | ||
| SGRToolCallingResearchAgent, | ||
| ToolCallingResearchAgent, | ||
| ) | ||
| from sgr_deep_research.core.models import AgentStatesEnum, ResearchContext, SearchResult, SourceData | ||
| from sgr_deep_research.core.prompts import PromptLoader | ||
| from sgr_deep_research.core.reasoning_schemas import * # noqa: F403 | ||
| from sgr_deep_research.core.stream import OpenAIStreamingGenerator | ||
| from sgr_deep_research.core.tools import * # noqa: F403 | ||
|
|
||
| __all__ = [ | ||
| # Agents | ||
| "BaseAgent", | ||
| "SGRResearchAgent", | ||
| "SGRToolCallingResearchAgent", | ||
| "SGRAutoToolCallingResearchAgent", | ||
| "ToolCallingResearchAgent", | ||
| "SGRSOToolCallingResearchAgent", | ||
| # Models | ||
| "AgentStatesEnum", | ||
| "ResearchContext", | ||
| "SearchResult", | ||
| "SourceData", | ||
| # Other core modules | ||
| "PromptLoader", | ||
| "OpenAIStreamingGenerator", | ||
| ] |
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.