t.me/xtekky
commited on
Commit
·
73618a9
1
Parent(s):
d0e9b9d
http://easy-ai.ink/
Browse files- unfinished/easyai/main.py +15 -9
unfinished/easyai/main.py
CHANGED
@@ -1,4 +1,8 @@
|
|
1 |
-
import
|
|
|
|
|
|
|
|
|
2 |
|
3 |
headers = {
|
4 |
'Accept': 'text/event-stream',
|
@@ -12,15 +16,17 @@ headers = {
|
|
12 |
}
|
13 |
|
14 |
while True:
|
|
|
|
|
15 |
params = {
|
16 |
-
'message':
|
17 |
-
'sessionId':
|
18 |
}
|
19 |
|
20 |
-
for chunk in
|
21 |
-
headers=headers,
|
22 |
-
|
23 |
-
if b'data:' in chunk:
|
24 |
-
print(chunk)
|
25 |
|
26 |
-
|
|
|
|
|
|
|
|
1 |
+
from requests import get
|
2 |
+
from os import urandom
|
3 |
+
from json import loads
|
4 |
+
|
5 |
+
sessionId = urandom(10).hex()
|
6 |
|
7 |
headers = {
|
8 |
'Accept': 'text/event-stream',
|
|
|
16 |
}
|
17 |
|
18 |
while True:
|
19 |
+
prompt = input('you: ')
|
20 |
+
|
21 |
params = {
|
22 |
+
'message': prompt,
|
23 |
+
'sessionId': sessionId
|
24 |
}
|
25 |
|
26 |
+
for chunk in get('http://easy-ai.ink/easyapi/v1/chat/completions', params = params,
|
27 |
+
headers = headers, verify = False, stream = True).iter_lines():
|
|
|
|
|
|
|
28 |
|
29 |
+
if b'content' in chunk:
|
30 |
+
data = loads(chunk.decode('utf-8').split('data:')[1])
|
31 |
+
print(data['content'], end='')
|
32 |
+
|