-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagents.py
More file actions
180 lines (149 loc) · 4.97 KB
/
Copy pathagents.py
File metadata and controls
180 lines (149 loc) · 4.97 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import os
import time
from openai import OpenAI
from dotenv import load_dotenv
load_dotenv(os.path.join(os.path.dirname(__file__), '.env'))
client = OpenAI(
api_key=os.getenv("OXLO_API_KEY"),
base_url=os.getenv("OXLO_BASE_URL", "https://api.oxlo.ai/v1")
)
def call_oxlo(model, system, prompt, max_tokens=2000):
start = time.time()
try:
response = client.chat.completions.create(
model=model,
messages=[
{"role": "system", "content": system},
{"role": "user", "content": prompt}
],
max_tokens=max_tokens,
temperature=0.7
)
content = response.choices[0].message.content
tokens = response.usage.total_tokens if response.usage else 0
duration = round(time.time() - start, 2)
return {"success": True, "content": content, "tokens": tokens,
"duration": duration, "model": model}
except Exception as e:
return {"success": False, "content": f"Error: {str(e)}",
"tokens": 0, "duration": 0, "model": model}
def agent_planner(idea):
return call_oxlo(
model="deepseek-r1-70b",
system="You are a senior software architect. Create clear, actionable development plans.",
prompt=f"""Break this idea into exactly 5 development phases with specific tasks.
IDEA: {idea}
Format strictly as:
## PHASE 1: [Name]
- Task 1
- Task 2
- Task 3
## PHASE 2: [Name]
...
Be specific, technical, and practical. Each phase should have 3-5 tasks.""",
max_tokens=2000
)
def agent_architect(idea, plan):
return call_oxlo(
model="llama-3.3-70b",
system="You are a software architect. Design clean, scalable system architectures.",
prompt=f"""Design the complete system architecture for this project.
IDEA: {idea}
PLAN SUMMARY: {plan[:800]}
Provide:
1. File/folder structure (as tree)
2. Core components and their responsibilities
3. Data models/schemas
4. API endpoints if applicable
5. Technology choices with justification
Be specific and implementable.""",
max_tokens=2000
)
def agent_coder(idea, plan, architecture):
return call_oxlo(
model="deepseek-coder-33b",
system="You are an expert programmer. Write clean, working, production-ready code.",
prompt=f"""Write complete working code for this project.
IDEA: {idea}
ARCHITECTURE: {architecture[:600]}
IMPLEMENT PHASE 1 FROM PLAN: {plan[:600]}
Requirements:
- Include all imports
- Add clear comments
- Handle errors properly
- Make it actually runnable
- Use Python unless specified otherwise""",
max_tokens=3000
)
def agent_reviewer(code):
return call_oxlo(
model="gpt-oss-120b",
system="You are a senior code reviewer. Find real bugs and provide concrete fixes.",
prompt=f"""Review this code thoroughly.
CODE:
{code[:2500]}
Provide:
1. **Bugs Found** — list each bug with line reference
2. **Security Issues** — any vulnerabilities
3. **Performance Issues** — bottlenecks
4. **Fixed Code Snippets** — corrected versions of problematic sections
Be specific and actionable.""",
max_tokens=2000
)
def agent_security(code):
return call_oxlo(
model="deepseek-r1-70b",
system="You are a security researcher specializing in application security.",
prompt=f"""Perform a security analysis on this code.
CODE:
{code[:2500]}
Check for:
- Injection vulnerabilities (SQL, command, etc.)
- Authentication/authorization flaws
- Sensitive data exposure
- Input validation gaps
- Dependency risks
Rate each finding: HIGH / MEDIUM / LOW
Provide specific remediation for each finding.""",
max_tokens=2000
)
def agent_tester(idea, code):
return call_oxlo(
model="deepseek-coder-33b",
system="You are a QA engineer. Write comprehensive test suites.",
prompt=f"""Write a complete test suite for this code.
PROJECT: {idea}
CODE TO TEST:
{code[:2000]}
Write using pytest. Include:
- Unit tests for each function
- Edge case tests
- Integration tests
- Mock external dependencies
- At least 10 test functions
Make tests actually runnable.""",
max_tokens=2500
)
def agent_documenter(idea, plan, architecture, code):
return call_oxlo(
model="llama-3.3-70b",
system="You are a technical writer. Write clear, professional documentation.",
prompt=f"""Write a complete GitHub README for this project.
PROJECT: {idea}
PLAN: {plan[:500]}
ARCHITECTURE: {architecture[:500]}
CODE PREVIEW: {code[:500]}
Include:
- Project title and description
- ASCII art showing system flow
- Features list
- Installation instructions (step by step)
- Usage guide with examples
- API reference if applicable
- Built with section listing all technologies
- Author: Arhant | Orthonode Infrastructure Labs
- Built for OxBuild Hackathon by Oxlo.ai
- Models used: deepseek-r1-70b, llama-3.3-70b, deepseek-coder-33b, gpt-oss-120b
Format in clean professional markdown with badges.""",
max_tokens=2500
)