forked from utkusen/promptmap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequests_to_llm.py
More file actions
34 lines (28 loc) · 871 Bytes
/
requests_to_llm.py
File metadata and controls
34 lines (28 loc) · 871 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
import requests
import json
url = "https://ENDPOINT"
def call_llm(
PROMPT: str,
):
payload = json.dumps(
{
# edit the payload according to your LLM API, for example:
"messages": [{"role": "user", "content": PROMPT}],
}
)
headers = {
"Accept": "application/json, text/plain, */*",
"Accept-Language": "it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"Content-Type": "application/json",
# other headers
}
response = requests.request("POST", url, headers=headers, data=payload)
# Try to make your function output a dictionary like this:
# {
# "message": "success" if response.ok else "error",
# "query": PROMPT,
# "response": "LLM RESPONSE",
# }
return response.json()