This commit is contained in:
parent
d0e9b9de97
commit
73618a9161
1 changed files with 15 additions and 9 deletions
|
@ -1,4 +1,8 @@
|
||||||
import requests
|
from requests import get
|
||||||
|
from os import urandom
|
||||||
|
from json import loads
|
||||||
|
|
||||||
|
sessionId = urandom(10).hex()
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
'Accept': 'text/event-stream',
|
'Accept': 'text/event-stream',
|
||||||
|
@ -12,15 +16,17 @@ headers = {
|
||||||
}
|
}
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
prompt = input('you: ')
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
'message': 'what is my name',
|
'message': prompt,
|
||||||
'sessionId': '2eacb8ad826056587598',
|
'sessionId': sessionId
|
||||||
}
|
}
|
||||||
|
|
||||||
for chunk in requests.get('http://easy-ai.ink/easyapi/v1/chat/completions', params=params,
|
for chunk in get('http://easy-ai.ink/easyapi/v1/chat/completions', params = params,
|
||||||
headers=headers, verify=False, stream=True).iter_lines():
|
headers = headers, verify = False, stream = True).iter_lines():
|
||||||
|
|
||||||
if b'data:' in chunk:
|
if b'content' in chunk:
|
||||||
print(chunk)
|
data = loads(chunk.decode('utf-8').split('data:')[1])
|
||||||
|
print(data['content'], end='')
|
||||||
|
|
||||||
print(chunk)
|
|
Loading…
Reference in a new issue