Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

How to continue an conversation? #19

Closed
CatAnonymous opened this issue May 18, 2023 · 7 comments
Closed

How to continue an conversation? #19

CatAnonymous opened this issue May 18, 2023 · 7 comments

Comments

@CatAnonymous
Copy link

CatAnonymous commented May 18, 2023

Can you show me what I need to save so that Bard can remember the previous conversation without starting a new one after each question?
I'm trying to write it on PHP

I used Chrome Dev Tools to monitor and found SNlM0e and conversation_id unchanged, I tried saving it again but the result is not as expected

@CatAnonymous
Copy link
Author

I think it is correct to get the conversation data (conversation_id...) somewhere before get_answer

@dsdanielpark
Copy link
Owner

Trying to stick more cookie information into the session and then proceeding may be able to fix it.

Try using a reusable session first, then stick more cookie values ​​to the session. If you find a solution, please contribute.

@dsdanielpark
Copy link
Owner

It was confirmed that the conversation can be continued through a reusable session. Use the following code. Close the issue.

from bardapi import Bard
import os
import requests

token='VwhVqhvFpnOm_sSsLszdru_DWm8otZBt3hPR9fud2BePGTk2jQmGmfcbKb_vyr3IjJFKEA.'
session = requests.Session()
session.headers = {
            "Host": "bard.google.com",
            "X-Same-Domain": "1",
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36",
            "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
            "Origin": "https://bard.google.com",
            "Referer": "https://bard.google.com/",
        }
session.cookies.set("__Secure-1PSID", token)

bard = Bard(token=token, timeout=30, session=session)
bard.get_answer("나와 내 동년배들이 좋아하는 뉴진스에 대해서 알려줘")['content']
bard.get_answer("What is my last prompt is?")['content']

@NightMachinery
Copy link

@dsdanielpark This re-usable session is the same as in the readme, correct? So one must not use sessions if one wants to reset the conversation?

Worth adding to the readme.

@dsdanielpark
Copy link
Owner

dsdanielpark commented May 18, 2023

@dsdanielpark This re-usable session is the same as in the readme, correct? So one must not use sessions if one wants to reset the conversation?

Worth adding to the readme.

In the current version of Bard, having extended conversations is limited due to its short session lengths. The Bard API serves as a more simplified version of chatting on the official Bard website.

The fact that Bards have a short memory implies that they don't update parameters during conversations, only keeping chat history for a brief period. To better understand how the Bard service operates, it's essential to explore its functionality with the large language model (LLM).

@CatAnonymous
Copy link
Author

@dsdanielpark This re-usable session is the same as in the readme, correct? So one must not use sessions if one wants to reset the conversation?
Worth adding to the readme.

In the current version of Bard, having extended conversations is limited due to its short session lengths. The Bard API serves as a more simplified version of chatting on the official Bard website.

The fact that Bards have a short memory implies that they don't update parameters during conversations, only keeping chat history for a brief period. To better understand how the Bard service operates, it's essential to explore its functionality with the large language model (LLM).

The way programming languages work is different . Basically, Bard's server will rely on the SNlM0e conversation_id choice_id response_id of the previous conversation and the new question to answer the question, if those elements are not found then the equivalent of a new conversation. So we need to save it after each response and send it again with the question to achieve the goal, I got it.

@dsdanielpark
Copy link
Owner

If you keep the session fixed and test it, you can receive the last prompt of the previous conversation as part of the result. Please confirm and let me know.

If that's not the case, it would be best to maintain the conversation history and continue the conversation based on that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants