Skip to content

Commit 4e5083d

Browse files
authored
Fixing codebase agent (#423)
Flushing out some details in agent implementation
1 parent 628acbf commit 4e5083d

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/codegen/extensions/langchain/agent.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from langchain import hub
44
from langchain.agents import AgentExecutor
55
from langchain.agents.openai_functions_agent.base import OpenAIFunctionsAgent
6-
from langchain_core.chat_history import ChatMessageHistory
6+
from langchain_community.chat_message_histories import ChatMessageHistory
77
from langchain_core.runnables.history import RunnableWithMessageHistory
88
from langchain_openai import ChatOpenAI
99

@@ -20,6 +20,7 @@
2020
RevealSymbolTool,
2121
SearchTool,
2222
SemanticEditTool,
23+
SemanticSearchTool,
2324
ViewFileTool,
2425
)
2526

@@ -59,6 +60,7 @@ def create_codebase_agent(
5960
MoveSymbolTool(codebase),
6061
RevealSymbolTool(codebase),
6162
SemanticEditTool(codebase),
63+
SemanticSearchTool(codebase),
6264
CommitTool(codebase),
6365
]
6466

src/codegen/extensions/langchain/tools.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -312,20 +312,18 @@ def _run(
312312
return json.dumps(result, indent=2)
313313

314314

315+
class SemanticSearchInput(BaseModel):
316+
query: str = Field(..., description="The natural language search query")
317+
k: int = Field(default=5, description="Number of results to return")
318+
preview_length: int = Field(default=200, description="Length of content preview in characters")
319+
320+
315321
class SemanticSearchTool(BaseTool):
316322
"""Tool for semantic code search."""
317323

318324
name: ClassVar[str] = "semantic_search"
319325
description: ClassVar[str] = "Search the codebase using natural language queries and semantic similarity"
320-
args_schema: ClassVar[type[BaseModel]] = type(
321-
"SemanticSearchInput",
322-
(BaseModel,),
323-
{
324-
"query": (str, Field(..., description="The natural language search query")),
325-
"k": (int, Field(default=5, description="Number of results to return")),
326-
"preview_length": (int, Field(default=200, description="Length of content preview in characters")),
327-
},
328-
)
326+
args_schema: ClassVar[type[BaseModel]] = SemanticSearchInput
329327
codebase: Codebase = Field(exclude=True)
330328

331329
def __init__(self, codebase: Codebase) -> None:

0 commit comments

Comments
 (0)