This commit is contained in:
Anish
2026-04-12 12:56:20 +05:30
parent 74b91cb3f3
commit 813755b879
6 changed files with 27 additions and 13 deletions

View File

@@ -12,19 +12,19 @@ from llm.cli.selector import interactive_select
__version__ = "0.1.0"
__all__ = [
"LLMProvider",
__all__ = (
"LLMInput",
"LLMOutput",
"LLMProvider",
"Message",
"get_provider",
"ToolCall",
"ToolDefinition",
"ToolResult",
"ToolExecutor",
"ToolRegistry",
"get_provider",
"interactive_select",
]
)
def gui() -> None:

View File

@@ -26,6 +26,7 @@ class Message:
content: str
name: str | None = None
tool_call_id: str | None = None
tool_calls: list[ToolCall] | None = None
def to_dict(self) -> dict[str, Any]:
result: dict[str, Any] = {"role": self.role.value, "content": self.content}
@@ -33,6 +34,11 @@ class Message:
result["name"] = self.name
if self.tool_call_id:
result["tool_call_id"] = self.tool_call_id
if self.tool_calls:
result["tool_calls"] = [
{"id": tc.id, "function": {"name": tc.name, "arguments": tc.arguments}}
for tc in self.tool_calls
]
return result

View File

@@ -3,11 +3,11 @@
from llm.prompt.builder import PromptBuilder, adapt_messages_for_provider, get_provider_builder
from llm.prompt.templates import TEMPLATES, get_template, get_template_or_default
__all__ = [
__all__ = (
"PromptBuilder",
"TEMPLATES",
"adapt_messages_for_provider",
"get_provider_builder",
"TEMPLATES",
"get_template",
"get_template_or_default",
]
)

View File

@@ -5,10 +5,10 @@ from llm.providers.openai import OpenAIProvider
from llm.providers.ollama import OllamaProvider
from llm.providers.resolver import get_provider, register_provider
__all__ = [
__all__ = (
"ClaudeProvider",
"OpenAIProvider",
"OllamaProvider",
"get_provider",
"register_provider",
]
)

View File

@@ -2,8 +2,8 @@
from llm.tools.executor import ReActAgent, ToolExecutor, ToolRegistry
__all__ = [
"ToolRegistry",
"ToolExecutor",
__all__ = (
"ReActAgent",
]
"ToolExecutor",
"ToolRegistry",
)

View File

@@ -91,6 +91,14 @@ class ReActAgent:
if not output.has_tool_calls:
return output
messages.append(
Message(
role=Role.ASSISTANT,
content=output.content or "",
tool_calls=output.tool_calls,
)
)
results = self.executor.execute_all(output.tool_calls)
for result in results: