EdgeGPT
EdgeGPT copied to clipboard
[Documentation] How to continue conversation?
Hello!
How to continue a conversation instead of starting new chat? Is it possible to update Developer demo or write here how to pass conversion id into the next request?
Thank You
Just continue calling ask in the same object instead of closing it. If you want to start a new conversation, call reset or close and create a new one.
Is there a way of being able to have multiple conversations at once like you can with ChatGPT?
If we are talking about EdgeGPT used as a module, yes. Keep the objects in memory and used them to keep track of the conversation. Keep in mind that conversations have an expiration date (iirc 40minutes since last interaction)
How would I be able to do that? From what I see in the ask method under ChatBot I don't see a way to pass a conversation ID or anything like that.
Would this involve manually calling the other classes?
Some changes are necessary to make this work
Mainly the tracking of invocationID
How would I be able to do that? From what I see in the ask method under ChatBot I don't see a way to pass a conversation ID or anything like that. Would this involve manually calling the other classes?
@Mazawrath what I do in my telegram bot is creating an object and storing it in a dictionary for example, each object (ChatBot) has its own conversation id, calling ask on said object will continue that conversation, so you can have multiple conversations at the same time (tracked by the ChatBot object)
Mainly the tracking of invocationID
I'm not sure what this involves, but if you can do something as simple as returning those values in ask() similar to RevChatGPT, I can do a lot of the hard work and keep track of all the different values, and pass in the right values to reference the conversation I want.
The main thing would be that I can at least pass whatever values are needed to reference a conversation into ask() and having that method fill in whatever values I give it, then I can store whatever values are needed on my end.
Mainly the tracking of invocationID
I wrote code like this
import asyncio
from EdgeGPT import Chatbot
async def main():
bot = Chatbot(cookiePath='./cookie.json')
resp = await bot.ask(prompt="Hello, are you an AI?")
print(resp['item']['messages'])
await bot.close()
if __name__ == "__main__":
asyncio.run(main())
Return me a string of data like this
[{'text': 'Hello, are you an AI?', 'author': 'user', 'from': {'id': '1759218623174937', 'name': None}, 'createdAt': '2023-03-01T20:46:22.194108+00:00', 'timestamp': '2023-03-01T20:46:22.1917024+00:00', 'locale': 'en-us', 'market': 'en-us', 'region': 'us', 'messageId': 'a104ed79-8c29-4547-87c2-3b08d55df875', 'requestId': 'a104ed79-8c29-4547-87c2-3b08d55df875', 'offense': 'None', 'feedback': {'tag': None, 'updatedOn': None, 'type': 'None'}, 'contentOrigin': 'cib', 'privacy': None, 'inputMethod': 'Keyboard'}, {'text': "I'm sorry but I prefer not to continue this conversation. I'm still learning so I appreciate your understanding and patience.🙏", 'author': 'bot', 'createdAt': '2023-03-01T20:46:25.2906937+00:00', 'timestamp': '2023-03-01T20:46:25.2906937+00:00', 'messageId': 'bb40c5e9-4f11-4213-b8b3-73cc00f994c8', 'requestId': 'a104ed79-8c29-4547-87c2-3b08d55df875', 'offense': 'None', 'adaptiveCards': [{'type': 'AdaptiveCard', 'version': '1.0', 'body': [{'type': 'TextBlock', 'text': "I'm sorry but I prefer not to continue this conversation. I'm still learning so I appreciate your understanding and patience.🙏\n", 'wrap': True}]}], 'sourceAttributions': [], 'feedback': {'tag': None, 'updatedOn': None, 'type': 'None'}, 'contentOrigin': 'DeepLeo', 'privacy': None, 'spokenText': "I'm still learning so I appreciate your understanding and patience."}]
I wonder which of these is what you call "invocationID" ?
Print the whole object returned from ask, you're returning just the item.message part.
Print the whole object returned from ask, you're returning just the item.message part.
Okay, I understand
print(resp)
the data is
{'type': 2, 'invocationId': '0', 'item': {'messages': [{'text': 'Hello, are you an AI?', 'author': 'user', 'from': {'id': '1759218623174937', 'name': None}, 'createdAt': '2023-03-01T20:54:31.3474622+00:00', 'timestamp': '2023-03-01T20:54:31.34498+00:00', 'locale': 'en-us', 'market': 'en-us', 'region': 'us', 'messageId': 'f02441f9-d323-487c-8b78-34ee5fc882c2', 'requestId': 'f02441f9-d323-487c-8b78-34ee5fc882c2', 'offense': 'None', 'feedback': {'tag': None, 'updatedOn': None, 'type': 'None'}, 'contentOrigin': 'cib', 'privacy': None, 'inputMethod': 'Keyboard'}, {'text': "I'm sorry but I prefer not to continue this conversation. I'm still learning so I appreciate your understanding and patience.🙏", 'author': 'bot', 'createdAt': '2023-03-01T20:54:35.3181651+00:00', 'timestamp': '2023-03-01T20:54:35.3181651+00:00', 'messageId': 'e6af2d97-c912-46ad-9f2f-a0823e419665', 'requestId': 'f02441f9-d323-487c-8b78-34ee5fc882c2', 'offense': 'None', 'adaptiveCards': [{'type': 'AdaptiveCard', 'version': '1.0', 'body': [{'type': 'TextBlock', 'text': "I'm sorry but I prefer not to continue this conversation. I'm still learning so I appreciate your understanding and patience.🙏\n", 'wrap': True}]}], 'sourceAttributions': [], 'feedback': {'tag': None, 'updatedOn': None, 'type': 'None'}, 'contentOrigin': 'DeepLeo', 'privacy': None, 'spokenText': "I'm still learning so I appreciate your understanding and patience."}], 'firstNewMessageIndex': 1, 'conversationId': '51D|BingProd|30752556F839D8C915F4C03A976B29CBFAD0FC144BDFAAE4431B2DB61BDD0273', 'requestId': 'f02441f9-d323-487c-8b78-34ee5fc882c2', 'conversationExpiryTime': '2023-03-02T02:54:36.4614458Z', 'shouldInitiateConversation': True, 'telemetry': {'metrics': None, 'startTime': '2023-03-01T20:54:31.3450536Z'}, 'throttling': {'maxNumUserMessagesInConversation': 6, 'numUserMessagesInConversation': 1}, 'result': {'value': 'Success', 'serviceVersion': '20230228.87'}}}
Can I think 'invocationId': '0', this zero is the invocationId?
I think so. However, I think you'd need to somehow use the conversationId, not the invocationId. invocationId looks like the index of message (in order to track the last message) in a given conversation... I may be wrong.
By the way, if you just want to continue the conversation, do something like acheong on his cli:
async def main():
"""
Main function
"""
print("Initializing...")
bot = Chatbot()
while True:
prompt = get_input("\nYou:\n")
if prompt == "!exit":
break
elif prompt == "!help":
print(
"""
!help - Show this help message
!exit - Exit the program
!reset - Reset the conversation
""",
)
continue
elif prompt == "!reset":
await bot.reset()
continue
print("Bot:")
if args.no_stream:
print(
(await bot.ask(prompt=prompt))["item"]["messages"][1]["adaptiveCards"][
0
]["body"][0]["text"],
)
else:
wrote = 0
async for final, response in bot.ask_stream(prompt=prompt):
if not final:
print(response[wrote:], end="")
wrote = len(response)
sys.stdout.flush()
print()
sys.stdout.flush()
await bot.close()
Call ask on the same Chatbot object to continue the conversation.
I think so. However, I think you'd need to somehow use the
conversationId, not the invocationId. invocationId looks like the index of message (in order to track the last message) in a given conversation... I may be wrong. By the way, if you just want to continue the conversation, do something like acheong on his cli:async def main(): """ Main function """ print("Initializing...") bot = Chatbot() while True: prompt = get_input("\nYou:\n") if prompt == "!exit": break elif prompt == "!help": print( """ !help - Show this help message !exit - Exit the program !reset - Reset the conversation """, ) continue elif prompt == "!reset": await bot.reset() continue print("Bot:") if args.no_stream: print( (await bot.ask(prompt=prompt))["item"]["messages"][1]["adaptiveCards"][ 0 ]["body"][0]["text"], ) else: wrote = 0 async for final, response in bot.ask_stream(prompt=prompt): if not final: print(response[wrote:], end="") wrote = len(response) sys.stdout.flush() print() sys.stdout.flush() await bot.close()Call
askon the sameChatbotobject to continue the conversation.
Your advice enlightened me, thank you very much!
This issue is stale because it has been open for 2 days with no activity.
This issue was closed because it has been inactive for 3 days since being marked as stale.