prevent infinite loop of getting relevant files

This commit is contained in:
LeonOstrez
2024-08-06 10:06:51 +02:00
parent 7bd4f1a7cf
commit 1c5ece7b9a
3 changed files with 15 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ from pydantic import BaseModel, Field
from core.agents.convo import AgentConvo
from core.agents.response import AgentResponse
from core.config import GET_RELEVANT_FILES_AGENT_NAME
from core.llm.parser import JSONParser
from core.log import get_logger
@@ -66,7 +67,7 @@ class RelevantFilesMixin:
done = False
relevant_files = set()
llm = self.get_llm()
llm = self.get_llm(GET_RELEVANT_FILES_AGENT_NAME)
convo = (
AgentConvo(self)
.template(
@@ -78,7 +79,7 @@ class RelevantFilesMixin:
.require_schema(RelevantFiles)
)
while not done:
while not done and len(convo.messages) < 13:
llm_response: RelevantFiles = await llm(convo, parser=JSONParser(RelevantFiles), temperature=0)
# Check if there are files to add to the list

View File

@@ -39,6 +39,7 @@ DESCRIBE_FILES_AGENT_NAME = "CodeMonkey.describe_files"
CHECK_LOGS_AGENT_NAME = "BugHunter.check_logs"
TASK_BREAKDOWN_AGENT_NAME = "Developer.breakdown_current_task"
SPEC_WRITER_AGENT_NAME = "SpecWriter"
GET_RELEVANT_FILES_AGENT_NAME = "get_relevant_files"
# Endpoint for the external documentation
EXTERNAL_DOCUMENTATION_API = "http://docs-pythagora-io-439719575.us-east-1.elb.amazonaws.com"
@@ -330,6 +331,7 @@ class Config(_StrictModel):
temperature=0.5,
),
SPEC_WRITER_AGENT_NAME: AgentLLMConfig(model="gpt-4-0125-preview", temperature=0.0),
GET_RELEVANT_FILES_AGENT_NAME: AgentLLMConfig(model="claude-3-5-sonnet-20240620", temperature=0.0),
}
)
prompt: PromptConfig = PromptConfig()

View File

@@ -2,7 +2,13 @@ Here is the current relevant files list:
{% if relevant_files %}{{ relevant_files }}{% else %}[]{% endif %}
Now, with multiple iterations you have to find relevant files for the current task. Here are commands that you can use:
- `read_file` - list of files that you want to read
- `add_file` - add file to the list of relevant files
- `remove_file` - remove file from the list of relevant files
- `finished` - boolean command that you will use when you finish with adding files
- `read_files` - List of files that you want to read.
- `add_files` - Add file to the list of relevant files.
- `remove_files` - Remove file from the list of relevant files.
- `finished` - Boolean command that you will use when you finish with finding relevant files.
Make sure to follow these rules:
- All files that you want to read or add to the list of relevant files, must exist in the project. Do not ask to read or add file that does not exist! In the first message you have list of all files that currently exist in the project.
- Do not repeat actions that you have already done. For example if you already added "index.js" to the list of relevant files you must not add it again.
- You must read the file before adding it to the list of relevant files. Do not `add_files` that you didn't read and see the content of the file.
- Focus only on your current task `{{ state.current_task.description }}` when selecting relevant files.