akborana4 commited on
Commit
74b03a1
·
verified ·
1 Parent(s): 390c10f

Create llm.py

Browse files
Files changed (1) hide show
  1. agent/llm.py +20 -0
agent/llm.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import requests
3
+
4
+ def call_llm(prompt):
5
+ key = os.getenv("OPENROUTER_API_KEY")
6
+ if not key:
7
+ return None
8
+
9
+ res = requests.post(
10
+ "https://openrouter.ai/api/v1/chat/completions",
11
+ headers={
12
+ "Authorization": f"Bearer {key}",
13
+ "Content-Type": "application/json"
14
+ },
15
+ json={
16
+ "model": os.getenv("MODEL_NAME"),
17
+ "messages": [{"role": "user", "content": prompt}]
18
+ }
19
+ )
20
+ return res.json()["choices"][0]["message"]["content"]