clonely updates

This commit is contained in:
George Kasparyants
2024-08-06 16:13:23 +03:00
parent 5176e3d664
commit d1d4e68458
4 changed files with 218 additions and 46 deletions

View File

@@ -1,4 +1,5 @@
from time import time
import urllib.parse
import requests
@@ -7,6 +8,12 @@ class AIHandler(object):
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",
@@ -28,9 +35,24 @@ class AIHandler(object):
"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)