Skip to content
This repository was archived by the owner on Aug 10, 2023. It is now read-only.

Commit c019c66

Browse files
author
Antonio Cheong
authored
Update docs for devs
1 parent 6cbb383 commit c019c66

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,16 @@ config = {
5858
chatbot = Chatbot(config, conversation_id=None)
5959
chatbot.reset_chat() # Forgets conversation
6060
chatbot.refresh_session() # Uses the session_token to get a new bearer token
61-
resp = chatbot.get_chat_response(prompt) # Sends a request to the API and returns the response by OpenAI
61+
resp = chatbot.get_chat_response(prompt, output="text") # Sends a request to the API and returns the response by OpenAI
6262
resp['message'] # The message sent by the response
6363
resp['conversation_id'] # The current conversation id
6464
resp['parent_id'] # The ID of the response
65+
66+
response = requests.post("https://chat.openai.com/backend-api/conversation", headers=self.headers, data=json.dumps(data), stream=True) # This returns a stream of text (live update)
67+
68+
for message in response: # You have to loop through the response stream
69+
print(line['message']) # Same format as text return type
70+
...
6571
```
6672
This can be imported to projects for bots and much more. You can have multiple independent conversations by keeping track of the conversation_id.
6773

0 commit comments

Comments
 (0)