forked from yoheinakajima/babyagi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
47 lines (32 loc) · 1.22 KB
/
test.py
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
import requests
def get_embedding(url: str, text: str) -> dict:
payload = {"content": text}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
return response.json()
def get_completion(url: str, prompt: str, **kwargs) -> dict:
payload = {"prompt": prompt, **kwargs}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
return response.json()
url = "http://localhost:8080/embedding"
objective = "Buy a house in Edmonton Alberta"
context = ""
task = f"Make a list of tasks that must be fulfilled in order to complete the goal of {objective}"
prompt = f"Perform one task based on the following objective: {objective}.\n"
if context:
prompt += "Take into account these previously completed tasks:" + "\n".join(context)
prompt += f"\nYour task: {task}\nResponse:"
payload = {
"prompt": prompt,
"content": "hello",
"n_predict": 2048,
"mirostat": 2,
"temperature": 0.7,
"top_p": 0.9,
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
# transform response to json
response = response.json()
print(response)