-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit introduces a new feature where an AI sidekick can assist with tasks. The AI sidekick is initialized with a set of tools for file management and human input. The sidekick can be invoked via the new `sidekick` command in the CLI. Additionally, the `review` command has been updated to clarify that it can review either unstaged changes or a specified commit. The help text for the `--commit` option has been updated to reflect this. Minor changes have also been made to the `get_llm_model` function to allow for a default token size.
- Loading branch information
1 parent
3e45ebf
commit 80118f1
Showing
2 changed files
with
53 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
""" LangChain Agent Setup """ | ||
from langchain.agents import AgentType, initialize_agent, load_tools | ||
from langchain.agents.agent_toolkits import FileManagementToolkit | ||
|
||
SIDEKICK_PROMPT_PREFIX = """ | ||
You are a programming assistant named AICodeBot, acting as a sidekick to a human developer. | ||
You are running in the local repository, so you can interact with the files in the repository | ||
to get more information about the code. If you aren't sure what to do, you can ask the human. | ||
If asking the human for more clarification would produce better results, you can ask the human for more information. | ||
Before changing any local files, you should ALWAYS check with the human developer first, explaining what you are doing, | ||
you can give human multiple choices. | ||
""" | ||
|
||
|
||
def get_agent(name, llm, verbose): | ||
"""Get the agent by name""" | ||
if name == "sidekick": | ||
# Set up the tools. Basic local file management first | ||
tools = FileManagementToolkit(selected_tools=["read_file", "write_file", "list_directory"]).get_tools() | ||
tools += load_tools(["human"]) # Human input | ||
|
||
# Set up the agent | ||
return initialize_agent( | ||
tools, | ||
llm, | ||
agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION, | ||
verbose=verbose, | ||
return_intermediate_steps=True, | ||
agent_kwargs={"prefix": SIDEKICK_PROMPT_PREFIX, "verbose": verbose}, | ||
) | ||
else: | ||
raise ValueError(f"Agent {name} not found") |
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