Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonOstrez committed Jul 25, 2024
2 parents a0feb85 + 775e4b5 commit 6933eb9
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 27 deletions.
4 changes: 2 additions & 2 deletions core/agents/code_monkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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.config import CODE_MONKEY_AGENT_NAME, DESCRIBE_FILES_AGENT_NAME
from core.llm.parser import JSONParser, OptionalCodeBlockParser
from core.log import get_logger

Expand Down Expand Up @@ -56,7 +56,7 @@ async def implement_changes(self) -> AgentResponse:
iterations = self.current_state.iterations
user_feedback = None
user_feedback_qa = None
llm = self.get_llm()
llm = self.get_llm(CODE_MONKEY_AGENT_NAME)

if "task_review_feedback" in task and task["task_review_feedback"]:
instructions = task.get("task_review_feedback")
Expand Down
22 changes: 11 additions & 11 deletions core/agents/troubleshooter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from core.agents.convo import AgentConvo
from core.agents.mixins import IterationPromptMixin
from core.agents.response import AgentResponse
from core.config import ROUTE_FILES_AGENT_NAME
from core.db.models.file import File
from core.db.models.project_state import IterationStatus, TaskStatus
from core.llm.parser import JSONParser, OptionalCodeBlockParser
Expand Down Expand Up @@ -47,7 +46,9 @@ async def propose_solution(self) -> AgentResponse:
user_feedback_qa = self.current_state.current_iteration.get("user_feedback_qa")
bug_hunting_cycles = self.current_state.current_iteration.get("bug_hunting_cycles")

llm_solution = await self.find_solution(user_feedback, user_feedback_qa=user_feedback_qa, bug_hunting_cycles=bug_hunting_cycles)
llm_solution = await self.find_solution(
user_feedback, user_feedback_qa=user_feedback_qa, bug_hunting_cycles=bug_hunting_cycles
)

self.next_state.current_iteration["description"] = llm_solution
self.next_state.current_iteration["status"] = IterationStatus.IMPLEMENT_SOLUTION
Expand Down Expand Up @@ -103,7 +104,6 @@ async def create_iteration(self) -> AgentResponse:
# this might be caused if we show the input field instead of buttons
iteration_status = IterationStatus.FIND_SOLUTION


self.next_state.iterations = self.current_state.iterations + [
{
"id": uuid4().hex,
Expand Down Expand Up @@ -189,7 +189,7 @@ async def get_user_instructions(self) -> Optional[str]:
async def _get_route_files(self) -> list[File]:
"""Returns the list of file paths that have routes defined in them."""

llm = self.get_llm(ROUTE_FILES_AGENT_NAME)
llm = self.get_llm()
convo = AgentConvo(self).template("get_route_files").require_schema(RouteFilePaths)
file_list = await llm(convo, parser=JSONParser(RouteFilePaths))
route_files: set[str] = set(file_list.files)
Expand Down Expand Up @@ -230,15 +230,13 @@ async def get_user_feedback(
if run_command:
await self.ui.send_run_command(run_command)

buttons = {
"continue": "Everything works",
"change": "I want to make a change",
"bug": "There is an issue"
}
buttons = {"continue": "Everything works", "change": "I want to make a change", "bug": "There is an issue"}
if last_iteration:
buttons["loop"] = "I'm stuck in a loop"

user_response = await self.ask_question(test_message, buttons=buttons, default="continue", buttons_only=True, hint=hint)
user_response = await self.ask_question(
test_message, buttons=buttons, default="continue", buttons_only=True, hint=hint
)
if user_response.button == "continue" or user_response.cancelled:
should_iterate = False

Expand All @@ -261,7 +259,9 @@ async def get_user_feedback(
is_loop = True

elif user_response.button == "change":
user_description = await self.ask_question("Please describe the change you want to make (one at the time please)")
user_description = await self.ask_question(
"Please describe the change you want to make (one at the time please)"
)
change_description = user_description.text

elif user_response.button == "bug":
Expand Down
6 changes: 3 additions & 3 deletions core/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@

# Agents with sane setup in the default configuration
DEFAULT_AGENT_NAME = "default"
CODE_MONKEY_AGENT_NAME = "CodeMonkey"
DESCRIBE_FILES_AGENT_NAME = "CodeMonkey.describe_files"
ROUTE_FILES_AGENT_NAME = "Troubleshooter.get_route_files"
CHECK_LOGS_AGENT_NAME = "BugHunter.check_logs"

# Endpoint for the external documentation
Expand Down Expand Up @@ -112,7 +112,7 @@ class AgentLLMConfig(_StrictModel):
"""

provider: LLMProvider = LLMProvider.OPENAI
model: str = Field(description="Model to use", default="gpt-4-0125-preview")
model: str = Field(description="Model to use", default="gpt-4o-2024-05-13")
temperature: float = Field(
default=0.5,
description="Temperature to use for sampling",
Expand Down Expand Up @@ -310,9 +310,9 @@ class Config(_StrictModel):
agent: dict[str, AgentLLMConfig] = Field(
default={
DEFAULT_AGENT_NAME: AgentLLMConfig(),
CODE_MONKEY_AGENT_NAME: AgentLLMConfig(model="gpt-4-0125-preview", temperature=0.0),
DESCRIBE_FILES_AGENT_NAME: AgentLLMConfig(model="gpt-3.5-turbo", temperature=0.0),
CHECK_LOGS_AGENT_NAME: AgentLLMConfig(model="claude-3-5-sonnet-20240620", temperature=0.0),
ROUTE_FILES_AGENT_NAME: AgentLLMConfig(model="gpt-4o", temperature=0.0),
}
)
prompt: PromptConfig = PromptConfig()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Then, upon implementing these changes, your colleague came back with the followi
{% endif %}

{% if user_input != '' %}
Your colleague who is testing the app "{{ name }}" sent you this report now:
Your colleague who is testing the app "{{ state.branch.project.name }}" sent you this report now:
```
{{ user_input }}
```
Expand Down
3 changes: 2 additions & 1 deletion core/prompts/troubleshooter/iteration.prompt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ You are working on an app called "{{ state.branch.project.name }}" and you need

{% if state.tasks and state.current_task %}
Development process of this app was split into smaller tasks. Here is the list of all tasks:
```{% for task in state.tasks %}
```
{% for task in state.tasks %}
{{ loop.index }}. {{ task.description }}
{% endfor %}
```
Expand Down
5 changes: 2 additions & 3 deletions core/templates/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from core.log import get_logger

from .javascript_react import JavascriptReactProjectTemplate
from .node_express_mongoose import NodeExpressMongooseProjectTemplate
from .react_express import ReactExpressProjectTemplate

Expand All @@ -12,13 +11,13 @@
class ProjectTemplateEnum(str, Enum):
"""Choices of available project templates."""

JAVASCRIPT_REACT = JavascriptReactProjectTemplate.name
# JAVASCRIPT_REACT = JavascriptReactProjectTemplate.name
NODE_EXPRESS_MONGOOSE = NodeExpressMongooseProjectTemplate.name
REACT_EXPRESS = ReactExpressProjectTemplate.name


PROJECT_TEMPLATES = {
JavascriptReactProjectTemplate.name: JavascriptReactProjectTemplate,
# JavascriptReactProjectTemplate.name: JavascriptReactProjectTemplate,
NodeExpressMongooseProjectTemplate.name: NodeExpressMongooseProjectTemplate,
ReactExpressProjectTemplate.name: ReactExpressProjectTemplate,
}
2 changes: 1 addition & 1 deletion example-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"agent": {
"default": {
"provider": "openai",
"model": "gpt-4o",
"model": "gpt-4o-2024-05-13",
"temperature": 0.5
},
"CodeMonkey": {
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "gpt-pilot"
version = "0.2.7"
version = "0.2.10"
description = "Build complete apps using AI agents"
authors = ["Senko Rasic <[email protected]>"]
license = "FSL-1.1-MIT"
Expand Down
4 changes: 2 additions & 2 deletions tests/agents/test_architect.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async def test_run(agentcontext):
side_effect=[
TemplateSelection(
architecture="dummy arch",
template="javascript_react",
template="node_express_mongoose",
),
Architecture(
system_dependencies=[
Expand Down Expand Up @@ -52,4 +52,4 @@ async def test_run(agentcontext):
assert sm.current_state.specification.architecture == "dummy arch"
assert sm.current_state.specification.system_dependencies[0]["name"] == "docker"
assert sm.current_state.specification.package_dependencies[0]["name"] == "express"
assert "javascript_react" in sm.current_state.specification.templates
assert "node_express_mongoose" in sm.current_state.specification.templates
2 changes: 1 addition & 1 deletion tests/agents/test_tech_lead.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async def test_create_initial_epic(agentcontext):
async def test_apply_project_template(agentcontext):
sm, _, ui, _ = agentcontext

sm.current_state.specification.templates = {"javascript_react": {}}
sm.current_state.specification.templates = {"node_express_mongoose": {}}
sm.current_state.epics = [{"name": "Initial Project"}]

await sm.commit()
Expand Down
2 changes: 1 addition & 1 deletion tests/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_builtin_defaults():
config = ConfigLoader.from_json("{}")

assert config.llm_for_agent().provider == LLMProvider.OPENAI
assert config.llm_for_agent().model == "gpt-4-0125-preview"
assert config.llm_for_agent().model == "gpt-4o-2024-05-13"
assert config.llm_for_agent().base_url is None
assert config.llm_for_agent().api_key is None

Expand Down
1 change: 1 addition & 0 deletions tests/templates/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ async def test_render_react_express_nosql(mock_get_config, testmanager):
assert "prisma/schema.prisma" not in files


@pytest.mark.skip
@pytest.mark.asyncio
@patch("core.state.state_manager.get_config")
async def test_render_javascript_react(mock_get_config, testmanager):
Expand Down

0 comments on commit 6933eb9

Please sign in to comment.