-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_generate.py
More file actions
36 lines (32 loc) · 1.03 KB
/
fix_generate.py
File metadata and controls
36 lines (32 loc) · 1.03 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
f = open('frontend/index.html', 'r', encoding='utf-8')
c = f.read()
f.close()
old_fetch = """ try {
const res = await fetch('https://api.anthropic.com/v1/messages', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': '',
'anthropic-version': '2023-06-01'
},
body: JSON.stringify({
model: 'claude-haiku-4-5-20251001',
max_tokens: 300,
messages: [{ role: 'user', content: agentPrompts[agent] + ' Input: ' + input }]
})
});
const data = await res.json();
const aiOutput = data.content[0].text;"""
new_fetch = """ try {
const res = await fetch(`${API}/api/generate-output`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ agent_id: agent, input_prompt: input })
});
const data = await res.json();
const aiOutput = data.output;"""
c = c.replace(old_fetch, new_fetch)
f = open('frontend/index.html', 'w', encoding='utf-8')
f.write(c)
f.close()
print('Done')