File size: 855 Bytes
a485cfb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cfce83b
 
a485cfb
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import websockets
from json import dumps, loads

async def test():
    async with websockets.connect('wss://chatgpt.func.icu/conversation+ws') as wss:
        
        await wss.send(dumps(separators=(',', ':'), obj = {
            'content_type':'text',
            'engine':'chat-gpt',
            'parts':['hello world'],
            'options':{}
            }
        ))
        
        ended = None

        while not ended:
            try:
                response      = await wss.recv()
                json_response = loads(response)
                print(json_response)
                
                ended         = json_response.get('eof')
                
                if not ended:
                    print(json_response['content']['parts'][0])
                
            except websockets.ConnectionClosed:
                break