clonely updates
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user