-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5_liar.py
40 lines (32 loc) · 1.01 KB
/
5_liar.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
import requests
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
from ai_devs import get_task, get_token, send_task
model = ChatOpenAI(model="gpt-3.5-turbo", temperature=0)
token = get_token("liar")
task = get_task(token, True)
def get_answer(token, debug=False):
url = "https://tasks.aidevs.pl/task/" + token
response = requests.post(url, data={"question": "What is capital city of Poland?"})
response.raise_for_status()
if debug:
print(response.json())
return response.json()
answer = get_answer(token, True)
prompt = ChatPromptTemplate.from_messages(
[
(
"system",
"""
You are working as a censor system.
Please check if this sentence is answer to question about capital city of Poland.
Answer only YES or NO.
""",
),
("user", "{input}"),
]
)
chain = prompt | model
response = chain.invoke({"input": answer["answer"]})
print(response.content)
send_task(token, response.content)