Comments (9)
Seems to be working again after making this change to core/agents/code_monkey.py L60:
if len(iterations) > 0:
if "description" in iterations[-1]:
instructions = iterations[-1]["description"]
if "user_feedback" in iterations[-1]:
user_feedback = iterations[-1]["user_feedback"]
if "user_feedback_qa" in iterations[-1]:
user_feedback_qa = iterations[-1]["user_feedback_qa"]
from gpt-pilot.
Same issue using repository except it happened without any inputs during code review. Restarting immediately fails again with the same message
from gpt-pilot.
same here
from gpt-pilot.
Resolved., Similar resolution to @DaveTacker
`from os.path import basename
from pydantic import BaseModel, Field
from core.agents.base import BaseAgent
from core.agents.convo import AgentConvo
from core.agents.response import AgentResponse, ResponseType
from core.config import DESCRIBE_FILES_AGENT_NAME
from core.llm.parser import JSONParser, OptionalCodeBlockParser
from core.log import get_logger
log = get_logger(name)
class FileDescription(BaseModel):
summary: str = Field(
description="Detailed description summarized what the file is about, and what the major classes, functions, elements or other functionality is implemented."
)
references: list[str] = Field(
description="List of references the file imports or includes (only files local to the project), where each element specifies the project-relative path of the referenced file, including the file extension."
)
class CodeMonkey(BaseAgent):
agent_type = "code-monkey"
display_name = "Code Monkey"
async def run(self) -> AgentResponse:
if self.prev_response and self.prev_response.type == ResponseType.DESCRIBE_FILES:
return await self.describe_files()
else:
return await self.implement_changes()
async def implement_changes(self) -> AgentResponse:
file_name = self.step["save_file"]["path"]
current_file = await self.state_manager.get_file_by_path(file_name)
file_content = current_file.content.content if current_file else ""
task = self.current_state.current_task
if self.prev_response and self.prev_response.type == ResponseType.CODE_REVIEW_FEEDBACK:
attempt = self.prev_response.data["attempt"] + 1
feedback = self.prev_response.data["feedback"]
log.debug(f"Fixing file {file_name} after review feedback: {feedback} ({attempt}. attempt)")
await self.send_message(f"Reworking changes I made to {file_name} ...")
else:
log.debug(f"Implementing file {file_name}")
await self.send_message(f"{'Updating existing' if file_content else 'Creating new'} file {file_name} ...")
self.next_state.action = (
f'Update file "{basename(file_name)}"' if file_content else f'Create file "{basename(file_name)}"'
)
attempt = 1
feedback = None
iterations = self.current_state.iterations
user_feedback = None
user_feedback_qa = None
llm = self.get_llm()
if iterations:
instructions = iterations[-1].get("description")
user_feedback = iterations[-1].get("user_feedback")
user_feedback_qa = iterations[-1].get("user_feedback_qa")
else:
instructions = self.current_state.current_task["instructions"]
convo = AgentConvo(self).template(
"implement_changes",
file_name=file_name,
file_content=file_content,
instructions=instructions,
user_feedback=user_feedback,
user_feedback_qa=user_feedback_qa,
)
if feedback:
convo.assistant(f"```\n{self.prev_response.data['new_content']}\n```\n").template(
"review_feedback",
content=self.prev_response.data["approved_content"],
original_content=file_content,
rework_feedback=feedback,
)
response: str = await llm(convo, temperature=0, parser=OptionalCodeBlockParser())
# FIXME: provide a counter here so that we don't have an endless loop here
return AgentResponse.code_review(self, file_name, task["instructions"], file_content, response, attempt)
async def describe_files(self) -> AgentResponse:
llm = self.get_llm(DESCRIBE_FILES_AGENT_NAME)
to_describe = {
file.path: file.content.content for file in self.current_state.files if not file.meta.get("description")
}
for file in self.next_state.files:
content = to_describe.get(file.path)
if content is None:
continue
if content == "":
file.meta = {
**file.meta,
"description": "Empty file",
"references": [],
}
continue
log.debug(f"Describing file {file.path}")
await self.send_message(f"Describing file {file.path} ...")
convo = (
AgentConvo(self)
.template(
"describe_file",
path=file.path,
content=content,
)
.require_schema(FileDescription)
)
llm_response: FileDescription = await llm(convo, parser=JSONParser(spec=FileDescription))
file.meta = {
**file.meta,
"description": llm_response.summary,
"references": llm_response.references,
}
return AgentResponse.done(self)
`
from gpt-pilot.
Here is the whole corrected code_monkey.py in gpt-pilot/core/agents
from os.path import basename
from pydantic import BaseModel, Field
from core.agents.base import BaseAgent
from core.agents.convo import AgentConvo
from core.agents.response import AgentResponse, ResponseType
from core.config import DESCRIBE_FILES_AGENT_NAME
from core.llm.parser import JSONParser, OptionalCodeBlockParser
from core.log import get_logger
log = get_logger(name)
class FileDescription(BaseModel):
summary: str = Field(
description="Detailed description summarized what the file is about, and what the major classes, functions, elements or other functionality is implemented."
)
references: list[str] = Field(
description="List of references the file imports or includes (only files local to the project), where each element specifies the project-relative path of the referenced file, including the file extension."
)
class CodeMonkey(BaseAgent):
agent_type = "code-monkey"
display_name = "Code Monkey"
async def run(self) -> AgentResponse:
if self.prev_response and self.prev_response.type == ResponseType.DESCRIBE_FILES:
return await self.describe_files()
else:
return await self.implement_changes()
async def implement_changes(self) -> AgentResponse:
file_name = self.step["save_file"]["path"]
current_file = await self.state_manager.get_file_by_path(file_name)
file_content = current_file.content.content if current_file else ""
task = self.current_state.current_task
if self.prev_response and self.prev_response.type == ResponseType.CODE_REVIEW_FEEDBACK:
attempt = self.prev_response.data["attempt"] + 1
feedback = self.prev_response.data["feedback"]
log.debug(f"Fixing file {file_name} after review feedback: {feedback} ({attempt}. attempt)")
await self.send_message(f"Reworking changes I made to {file_name} ...")
else:
log.debug(f"Implementing file {file_name}")
await self.send_message(f"{'Updating existing' if file_content else 'Creating new'} file {file_name} ...")
self.next_state.action = (
f'Update file "{basename(file_name)}"' if file_content else f'Create file "{basename(file_name)}"'
)
attempt = 1
feedback = None
iterations = self.current_state.iterations
user_feedback = None
user_feedback_qa = None
llm = self.get_llm()
if iterations:
if "description" in iterations[-1]:
instructions = iterations[-1]["description"]
if "user_feedback" in iterations[-1]:
user_feedback = iterations[-1]["user_feedback"]
if "user_feedback_qa" in iterations[-1]:
user_feedback_qa = iterations[-1]["user_feedback_qa"]
else:
instructions = self.current_state.current_task["instructions"]
convo = AgentConvo(self).template(
"implement_changes",
file_name=file_name,
file_content=file_content,
instructions=instructions,
user_feedback=user_feedback,
user_feedback_qa=user_feedback_qa,
)
if feedback:
convo.assistant(f"```\n{self.prev_response.data['new_content']}\n```\n").template(
"review_feedback",
content=self.prev_response.data["approved_content"],
original_content=file_content,
rework_feedback=feedback,
)
response: str = await llm(convo, temperature=0, parser=OptionalCodeBlockParser())
# FIXME: provide a counter here so that we don't have an endless loop here
return AgentResponse.code_review(self, file_name, task["instructions"], file_content, response, attempt)
async def describe_files(self) -> AgentResponse:
llm = self.get_llm(DESCRIBE_FILES_AGENT_NAME)
to_describe = {
file.path: file.content.content for file in self.current_state.files if not file.meta.get("description")
}
for file in self.next_state.files:
content = to_describe.get(file.path)
if content is None:
continue
if content == "":
file.meta = {
**file.meta,
"description": "Empty file",
"references": [],
}
continue
log.debug(f"Describing file {file.path}")
await self.send_message(f"Describing file {file.path} ...")
convo = (
AgentConvo(self)
.template(
"describe_file",
path=file.path,
content=content,
)
.require_schema(FileDescription)
)
llm_response: FileDescription = await llm(convo, parser=JSONParser(spec=FileDescription))
file.meta = {
**file.meta,
"description": llm_response.summary,
"references": llm_response.references,
}
return AgentResponse.done(self)
from gpt-pilot.
`from os.path import basename
from pydantic import BaseModel, Field
from core.agents.base import BaseAgent
from core.agents.convo import AgentConvo
from core.agents.response import AgentResponse, ResponseType
from core.config import DESCRIBE_FILES_AGENT_NAME
from core.llm.parser import JSONParser, OptionalCodeBlockParser
from core.log import get_logger
log = get_logger(name)
class FileDescription(BaseModel):
summary: str = Field(
description="Detailed description summarized what the file is about, and what the major classes, functions, elements or other functionality is implemented."
)
references: list[str] = Field(
description="List of references the file imports or includes (only files local to the project), where each element specifies the project-relative path of the referenced file, including the file extension."
)
class CodeMonkey(BaseAgent):
agent_type = "code-monkey"
display_name = "Code Monkey"
async def run(self) -> AgentResponse:
if self.prev_response and self.prev_response.type == ResponseType.DESCRIBE_FILES:
return await self.describe_files()
else:
return await self.implement_changes()
async def implement_changes(self) -> AgentResponse:
file_name = self.step["save_file"]["path"]
current_file = await self.state_manager.get_file_by_path(file_name)
file_content = current_file.content.content if current_file else ""
task = self.current_state.current_task
if self.prev_response and self.prev_response.type == ResponseType.CODE_REVIEW_FEEDBACK:
attempt = self.prev_response.data["attempt"] + 1
feedback = self.prev_response.data["feedback"]
log.debug(f"Fixing file {file_name} after review feedback: {feedback} ({attempt}. attempt)")
await self.send_message(f"Reworking changes I made to {file_name} ...")
else:
log.debug(f"Implementing file {file_name}")
await self.send_message(f"{'Updating existing' if file_content else 'Creating new'} file {file_name} ...")
self.next_state.action = (
f'Update file "{basename(file_name)}"' if file_content else f'Create file "{basename(file_name)}"'
)
attempt = 1
feedback = None
iterations = self.current_state.iterations
user_feedback = None
user_feedback_qa = None
llm = self.get_llm()
if iterations:
last_iteration = iterations[-1]
instructions = last_iteration.get("description", "")
user_feedback = last_iteration.get("user_feedback", None)
user_feedback_qa = last_iteration.get("user_feedback_qa", None)
else:
instructions = self.current_state.current_task["instructions"]
convo = AgentConvo(self).template(
"implement_changes",
file_name=file_name,
file_content=file_content,
instructions=instructions,
user_feedback=user_feedback,
user_feedback_qa=user_feedback_qa,
)
if feedback:
convo.assistant(f"```\n{self.prev_response.data['new_content']}\n```\n").template(
"review_feedback",
content=self.prev_response.data["approved_content"],
original_content=file_content,
rework_feedback=feedback,
)
response: str = await llm(convo, temperature=0, parser=OptionalCodeBlockParser())
# FIXME: provide a counter here so that we don't have an endless loop here
return AgentResponse.code_review(self, file_name, task["instructions"], file_content, response, attempt)
async def describe_files(self) -> AgentResponse:
llm = self.get_llm(DESCRIBE_FILES_AGENT_NAME)
to_describe = {
file.path: file.content.content for file in self.current_state.files if not file.meta.get("description")
}
for file in self.next_state.files:
content = to_describe.get(file.path)
if content is None:
continue
if content == "":
file.meta = {
**file.meta,
"description": "Empty file",
"references": [],
}
continue
log.debug(f"Describing file {file.path}")
await self.send_message(f"Describing file {file.path} ...")
convo = (
AgentConvo(self)
.template(
"describe_file",
path=file.path,
content=content,
)
.require_schema(FileDescription)
)
llm_response: FileDescription = await llm(convo, parser=JSONParser(spec=FileDescription))
file.meta = {
**file.meta,
"description": llm_response.summary,
"references": llm_response.references,
}
return AgentResponse.done(self)
`
This version of the CodeMonkey class ensures that the keys description, user_feedback, and user_feedback_qa are accessed safely using the get method, preventing KeyError exceptions if these keys are missing.
from gpt-pilot.
This is strange because I had the same solution from chatgtp but it didn't work and even after copying your code still does not work. pythagora won't load the window to upload or create a new application. I wonder how its gonna be before the bug is ironed out. I have tried this in both windows 10 and 11. please help mybe am doing something wrong
from gpt-pilot.
from gpt-pilot.
Is it exactly the same error?
yes
On the side note: I have realised that the errors are caused by skipping filling out .env variables. That means you have to have all the services set before you start coding and fillout all the required information, then you are good to go. I have not had those errors anymore.
from gpt-pilot.
Related Issues (20)
- [Bug]: can't find python file. HOT 2
- [Bug]: When selecting "Load App", I get a spin wheel. HOT 4
- [Bug]: Crash when running python main.py: MissingGreenlet: greenlet_spawn has not been called HOT 3
- [Bug]: AttributeError: 'SpecWriter' object has no attribute 'telemetry' HOT 2
- [Enhancement]: MS-SQL Support
- [Howto]: i accidently closed the app tab
- [Bug]:After loading the app, the front-end reported an error: Error connecting to the LLM: API error: Error code: 400 - {'error': {'message': 'Unrecognized request argument supplied: stream_options (request id: 20240617162225973326812zW5O0B98)', 'type': 'invalid_request_error', 'param': '', 'code': None}}
- Error connecting to the LLM: Error parsing response: Expected a single code block, got 0[Pythagora] Would you like to retry the failed request?
- [Bug]: New claude sonnet adds comments/descriptions into code files, making them unusable HOT 3
- [Bug]: New Claude Sonnet CodeMonkey describes every file in env
- [Bug]: API error: Error code: 400 - {'error': {'message': "Unknown parameter: 'stream_options' HOT 4
- [Bug]: ValueError: Empty message content HOT 3
- [Bug]: HOT 2
- [Bug]: Added my own openai key but still won't let me proceed.
- [Howto]: I have deployed GPT Pilot on a new computer. How to synchronize the app to the new computer HOT 1
- [Bug]: node_sqlite3.node is not a valid Win32 application HOT 1
- [Enhancement]: Gemini Support HOT 1
- [Howto]: set up the llm studio Meta-Llama-3-8B-Instruct-GGUF model in gpt pilot 0.2 in local system
- [Howto]: Complete The New Step Six? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gpt-pilot.