gpt4free icon indicating copy to clipboard operation
gpt4free copied to clipboard

How to continue the chat?

Open 64chevy opened this issue 1 year ago • 13 comments

How do i reply to an answer? Continue chatting with GPT.

Scenario: I am asking gpt 3.5 to fetch some info --- I have to ask "Fetch another one" and then again "Fetch another one"

64chevy avatar Jul 03 '23 23:07 64chevy

maybe this late, just pass previous message you send and ai response to next request. just remember to give role to each messages, ai = assistant/system and you = user

[
    {'role': 'user', 'content': 'first chat you sending...'},
    {'role': 'assistant', 'content': 'Firs ai response'},
    {'role': 'user', 'content': 'second message to response to ai'},
]

also accurate to remember context and memory depends on provider you choose

bagusindrayana avatar Jul 11 '23 17:07 bagusindrayana

maybe this late, just pass previous message you send and ai response to next request. just remember to give role to each messages, ai = assistant/system and you = user

[
    {'role': 'user', 'content': 'first chat you sending...'},
    {'role': 'assistant', 'content': 'Firs ai response'},
    {'role': 'user', 'content': 'second message to response to ai'},
]

also accurate to remember context and memory depends on provider you choose

It does not take effect on the gpt-3.5-turbo model

Heliner avatar Aug 23 '23 09:08 Heliner

maybe this late, just pass previous message you send and ai response to next request. just remember to give role to each messages, ai = assistant/system and you = user

[
    {'role': 'user', 'content': 'first chat you sending...'},
    {'role': 'assistant', 'content': 'Firs ai response'},
    {'role': 'user', 'content': 'second message to response to ai'},
]

also accurate to remember context and memory depends on provider you choose

It does not take effect on the gpt-3.5-turbo model

what provider?

bagusindrayana avatar Aug 23 '23 11:08 bagusindrayana

Basically, this project (at least Bard) does not support it, if you want to, you must provide conversation_id, response_id and choice_id of the chat that you wish to continue. There also a Bard git repository call Bard-API that let you continue as you like.

AmayaKuro avatar Aug 27 '23 10:08 AmayaKuro

Bumping this issue because it has been open for 7 days with no activity. Closing automatically in 7 days unless it becomes active again.

github-actions[bot] avatar Sep 04 '23 00:09 github-actions[bot]

Basically, this project (at least Bard) does not support it, if you want to, you must provide conversation_id, response_id and choice_id of the chat that you wish to continue. There also a Bard git repository call Bard-API that let you continue as you like.

Thank you for your answer, it seems that not all providers support language context

Heliner avatar Sep 04 '23 04:09 Heliner

maybe this late, just pass previous message you send and ai response to next request. just remember to give role to each messages, ai = assistant/system and you = user

[
    {'role': 'user', 'content': 'first chat you sending...'},
    {'role': 'assistant', 'content': 'Firs ai response'},
    {'role': 'user', 'content': 'second message to response to ai'},
]

also accurate to remember context and memory depends on provider you choose

I write this code, By examining the source code, its provider is identified as GetGpt.

model = 'gpt-3.5-turbo'
response = g4f.ChatCompletion.create(
    model=model,
    messages=[{"role": "user", "content": "Now you are Cortana"}],
    stream=False,
)

for message in response:
    print(message, flush=True, end='')

response = g4f.ChatCompletion.create(
    model=model,
    messages=[
        {'role': 'user', 'content': 'Suppose you are Cortana now'},
        {"role": "user", "content": "who are you"},
    ],
    stream=False,
)

print("\n-----------\n")

for message in response:
    print(message, flush=True, end='')

Heliner avatar Sep 04 '23 04:09 Heliner

Is there a flag or similar to detect if a provider is supporting conversation history?

C0untFloyd avatar Sep 14 '23 15:09 C0untFloyd

maybe this late, just pass previous message you send and ai response to next request. just remember to give role to each messages, ai = assistant/system and you = user

[
    {'role': 'user', 'content': 'first chat you sending...'},
    {'role': 'assistant', 'content': 'Firs ai response'},
    {'role': 'user', 'content': 'second message to response to ai'},
]

also accurate to remember context and memory depends on provider you choose

This worked for me with every provider I tried, even Bard, thanks OP!

C0untFloyd avatar Sep 15 '23 19:09 C0untFloyd

Bumping this issue because it has been open for 7 days with no activity. Closing automatically in 7 days unless it becomes active again.

github-actions[bot] avatar Sep 29 '23 00:09 github-actions[bot]

These codes can implement the function of continuing to ask. `import g4f

first=0 RepleyText="" MessageStorage=[] questionNum=15 while True: question=input("You:") if first==0: MessageStorage=[{'role': 'user', 'content': question}] else: MessageStorage.append({'role': 'user', 'content': question}) response = g4f.ChatCompletion.create( model="gpt-3.5-turbo", messages=MessageStorage, stream=True, ) first+=1 RepleyText="" for message in response: print(message, flush=True, end='') RepleyText+=message print() if first < questionNum: MessageStorage.append({'role': 'assistant', 'content': RepleyText}) else: del MessageStorage[0] del MessageStorage[0] MessageStorage.append({'role': 'assistant', 'content': RepleyText}) `

tianlichunhong avatar Sep 30 '23 10:09 tianlichunhong

Bumping this issue because it has been open for 7 days with no activity. Closing automatically in 7 days unless it becomes active again.

github-actions[bot] avatar Oct 09 '23 00:10 github-actions[bot]