Skip to content

Commit

Permalink
http://easy-ai.ink/
Browse files Browse the repository at this point in the history
  • Loading branch information
xtekky committed Apr 26, 2023
1 parent d0e9b9d commit 73618a9
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions unfinished/easyai/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import requests
from requests import get
from os import urandom
from json import loads

sessionId = urandom(10).hex()

headers = {
'Accept': 'text/event-stream',
Expand All @@ -12,15 +16,17 @@
}

while True:
prompt = input('you: ')

params = {
'message': 'what is my name',
'sessionId': '2eacb8ad826056587598',
'message': prompt,
'sessionId': sessionId
}

for chunk in requests.get('http://easy-ai.ink/easyapi/v1/chat/completions', params=params,
headers=headers, verify=False, stream=True).iter_lines():

if b'data:' in chunk:
print(chunk)
for chunk in get('http://easy-ai.ink/easyapi/v1/chat/completions', params = params,
headers = headers, verify = False, stream = True).iter_lines():

print(chunk)
if b'content' in chunk:
data = loads(chunk.decode('utf-8').split('data:')[1])
print(data['content'], end='')

0 comments on commit 73618a9

Please sign in to comment.