-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_coding_agent.py
More file actions
40 lines (35 loc) · 1018 Bytes
/
Copy pathpython_coding_agent.py
File metadata and controls
40 lines (35 loc) · 1018 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
33
34
35
36
37
38
39
40
import warnings
warnings.filterwarnings("ignore")
from typing import Callable
from helper import load_env, get_openai_api_key
from openai import OpenAI
from llm import LLM
from typing import TypedDict
import sys
from io import StringIO
from tools import execute_code_schema
from execute_tool import execute_tool
from Execution import execute_code
import tools
client = OpenAI(
base_url="https://openrouter.ai/api/v1",
api_key=get_openai_api_key(),
)
messages = [{
"role": "user",
"content": "Hello, I am a Python coding agent. How can I assist you today?"
}]
system_prompt = (
"You are a helpful Python coding agent. You will be given a task in Python. "
"Respond with code only, no explanations."
)
response = LLM(
client,
messages,
model="mistralai/mistral-nemo",
system_prompt=system_prompt
).get_response()
print(response)
result = execute_code(response)
print("Results:", result["results"])
print("Errors:", result["errors"])