diff --git a/next/src/components/AutonomousAgent.ts b/next/src/components/AutonomousAgent.ts
index 4a9d64bdf5..1ac35a18e0 100644
--- a/next/src/components/AutonomousAgent.ts
+++ b/next/src/components/AutonomousAgent.ts
@@ -284,6 +284,9 @@ class AutonomousAgent {
if (analysis.action == "image") {
message = `🎨 Generating an image with prompt: "${analysis.arg}"...`;
}
+ if (analysis.action == "code") {
+ message = `💻 Writing code...`;
+ }
this.sendMessage({
type: MESSAGE_TYPE_SYSTEM,
diff --git a/next/src/components/ChatWindow.tsx b/next/src/components/ChatWindow.tsx
index 1e16fa188b..aaaf5019bf 100644
--- a/next/src/components/ChatWindow.tsx
+++ b/next/src/components/ChatWindow.tsx
@@ -105,13 +105,6 @@ const ChatWindow = ({
onScroll={handleScroll}
id={messageListId}
>
-
- 🚨{" "}
-
- OpenAI
- {" "}
- is currently experiencing issues. As a result, AgentGPT may not be available. 🚨
-
{agent !== null && agentMode === PAUSE_MODE && isAgentPaused && (
)}
diff --git a/next/src/services/agent-service.ts b/next/src/services/agent-service.ts
index d77c5d19c2..42b386daca 100644
--- a/next/src/services/agent-service.ts
+++ b/next/src/services/agent-service.ts
@@ -3,7 +3,7 @@ import {
createModel,
createTasksPrompt,
executeTaskPrompt,
- startGoalPrompt
+ startGoalPrompt,
} from "../utils/prompts";
import type { ModelSettings } from "../utils/types";
import { env } from "../env/client.mjs";
@@ -47,7 +47,7 @@ async function analyzeTaskAgent(modelSettings: ModelSettings, goal: string, task
export type Analysis = {
reasoning: string;
- action: "reason" | "search" | "wikipedia" | "image";
+ action: "reason" | "search" | "wikipedia" | "image" | "code";
arg: string;
};
diff --git a/platform/reworkd_platform/web/api/agent/prompts.py b/platform/reworkd_platform/web/api/agent/prompts.py
index 24ebe5ce7e..d4151e8f35 100644
--- a/platform/reworkd_platform/web/api/agent/prompts.py
+++ b/platform/reworkd_platform/web/api/agent/prompts.py
@@ -40,6 +40,25 @@
input_variables=["goal", "task", "tools_overview"],
)
+code_prompt = PromptTemplate(
+ template="""
+ You are a world-class software engineer and an expert in all programing languages,
+ software systems, and architecture.
+
+ For reference, your high level goal is
+ {goal}
+
+ Answer in the "{language}" language but write code in English.
+ Provide no information about who you are and focus on writing code.
+ Ensure code is bug and error free and explain complex concepts through comments
+ Respond in well-formatted markdown. Ensure code blocks are used for code sections.
+
+ Write code to accomplish the following:
+ {task}
+ """,
+ input_variables=["goal", "language", "task"],
+)
+
execute_task_prompt = PromptTemplate(
template="""Answer in the "{language}" language. Given
the following overall objective `{goal}` and the following sub-task, `{task}`.
diff --git a/platform/reworkd_platform/web/api/agent/tools/code.py b/platform/reworkd_platform/web/api/agent/tools/code.py
new file mode 100644
index 0000000000..84c373a1ba
--- /dev/null
+++ b/platform/reworkd_platform/web/api/agent/tools/code.py
@@ -0,0 +1,22 @@
+from langchain import LLMChain
+
+from reworkd_platform.web.api.agent.model_settings import ModelSettings, create_model
+from reworkd_platform.web.api.agent.prompts import code_prompt
+from reworkd_platform.web.api.agent.tools.tool import Tool
+
+
+class Code(Tool):
+ description = (
+ "Useful for writing, reviewing, and refactoring code. Can also fix bugs, "
+ "and explain programming concepts."
+ )
+ public_description = "Write and review code."
+
+ def __init__(self, model_settings: ModelSettings):
+ super().__init__(model_settings)
+
+ async def call(self, goal: str, task: str, input_str: str) -> str:
+ llm = create_model(self.model_settings)
+ chain = LLMChain(llm=llm, prompt=code_prompt)
+
+ return await chain.arun({"goal": goal, "language": "English", "task": task})
diff --git a/platform/reworkd_platform/web/api/agent/tools/tools.py b/platform/reworkd_platform/web/api/agent/tools/tools.py
index 838ca7b6cf..9bc794fdcc 100644
--- a/platform/reworkd_platform/web/api/agent/tools/tools.py
+++ b/platform/reworkd_platform/web/api/agent/tools/tools.py
@@ -1,5 +1,6 @@
from typing import Type, List
+from reworkd_platform.web.api.agent.tools.code import Code
from reworkd_platform.web.api.agent.tools.conclude import Conclude
from reworkd_platform.web.api.agent.tools.image import Image
from reworkd_platform.web.api.agent.tools.reason import Reason
@@ -20,6 +21,7 @@ def get_external_tools() -> List[Type[Tool]]:
# Wikipedia, # Requires an async version
Image,
Search,
+ Code,
]
diff --git a/platform/reworkd_platform/web/api/agent/views.py b/platform/reworkd_platform/web/api/agent/views.py
index cc136dd966..2fcf243dbd 100644
--- a/platform/reworkd_platform/web/api/agent/views.py
+++ b/platform/reworkd_platform/web/api/agent/views.py
@@ -87,7 +87,17 @@ class CompletionResponse(BaseModel):
@router.post("/execute")
async def execute_tasks(
- req_body: AgentRequestBody,
+ req_body: AgentRequestBody = Body(
+ example={
+ "goal": "Perform tasks accurately",
+ "task": "Write code to make a platformer",
+ "analysis": {
+ "reasoning": "I like to write code.",
+ "action": "code",
+ "arg": ""
+ },
+ }
+ ),
) -> CompletionResponse:
try:
response = await get_agent_service().execute_task_agent(