-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoding_agent.py
More file actions
32 lines (25 loc) · 810 Bytes
/
Copy pathcoding_agent.py
File metadata and controls
32 lines (25 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from openai import OpenAI
from llm import LLM
from typing import Callable
from execute_tool import execute_tool
from tools import execute_code_schema
from helper import get_openai_api_key
from Execution import execute_code
def coding_agent(
client: OpenAI,
query: str,
system: str,
tools: dict[str, Callable],
tools_schemas: list[dict]
):
messages = [
{"role": "system", "content": system},
{"role": "user", "content": query}
]
# Get LLM output (this is JUST a string)
response = LLM(client, messages, system).get_response()
print("Response:\n", response)
# Direct execution (NO tool system here)
result = execute_code(response)
print("Results:", result["results"])
print("Errors:", result["errors"])