Files
George Kasparyants d1d4e68458 clonely updates
2024-08-06 16:13:23 +03:00

59 lines
2.1 KiB
Python

from time import time
import urllib.parse
import requests
class AIHandler(object):
def __init__(self):
pass
def __call__(self, text):
"""
resp = requests.get(f"https://ai.travely24.com/generate?input_query={urllib.parse.quote_plus(text)}",
headers={"accept": "application/json"},
stream=True)
"""
resp = requests.post("https://fast-pia.avemio.technology/chat-completion",
json={
"session-id": "chatcmpl",
"user-location": "Zweibrücken",
"wheel-of-life": [
{
"personal_growth": 10,
"health_exercise": 5,
"familiy_friends": 5,
"romance_relationship": 5,
"career_work": 5,
"finances": 5,
"recreation_fun": 5,
"living_situation": 5}
],
"messages": [
{
"role": "user",
"content": text
}
]
},
headers={"accept": "application/json"},
stream=True)
resp = resp.json()
return {
"text": resp[0]['text'],
"emotion": resp[0]['emotion']
}
"""
for chunk in resp.iter_content(chunk_size=1024):
if chunk:
yield str(chunk)
"""
if __name__ == "__main__":
aihandler = AIHandler()
t1 = time()
for text in aihandler("Hello, how are you, what is your name?"):
print(time() - t1)
print(text)