summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authort.me/xtekky <98614666+xtekky@users.noreply.github.com>2023-04-26 13:12:05 +0200
committert.me/xtekky <98614666+xtekky@users.noreply.github.com>2023-04-26 13:12:05 +0200
commit73618a91618a4f7e39acf0f890ba0fe510175022 (patch)
tree624ce408c69891831a169822ab6f468b8a993588
parent. (diff)
downloadgpt4free-73618a91618a4f7e39acf0f890ba0fe510175022.tar
gpt4free-73618a91618a4f7e39acf0f890ba0fe510175022.tar.gz
gpt4free-73618a91618a4f7e39acf0f890ba0fe510175022.tar.bz2
gpt4free-73618a91618a4f7e39acf0f890ba0fe510175022.tar.lz
gpt4free-73618a91618a4f7e39acf0f890ba0fe510175022.tar.xz
gpt4free-73618a91618a4f7e39acf0f890ba0fe510175022.tar.zst
gpt4free-73618a91618a4f7e39acf0f890ba0fe510175022.zip
-rw-r--r--unfinished/easyai/main.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/unfinished/easyai/main.py b/unfinished/easyai/main.py
index 0607d58a..3b246977 100644
--- a/unfinished/easyai/main.py
+++ b/unfinished/easyai/main.py
@@ -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',
@@ -12,15 +16,17 @@ headers = {
}
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) \ No newline at end of file
+ if b'content' in chunk:
+ data = loads(chunk.decode('utf-8').split('data:')[1])
+ print(data['content'], end='')
+ \ No newline at end of file