agentic icon indicating copy to clipboard operation
agentic copied to clipboard

How to let ChatGPT understand the context?

Open gefeiyanga opened this issue 2 years ago • 4 comments

I want to let ChatGPT understand the context like the official ChatGPT, not just understand one paragraph. Someone can help me, thank you!

Sent from PPHub

gefeiyanga avatar Feb 10 '23 13:02 gefeiyanga

I've asked a similar question a few hours ago. ChatGPT answered:

The context of the conversation is provided to me as a sequence of input tokens, where each token represents a word or subword in the input text. In the context of a conversation, the context is the sequence of messages previously exchanged between the user and the AI.

To be more accurate, I asked if the context needed to be provided again with the new text:

Yes, in a scenario where the input text evolves over time, the model works in a similar manner. The new input text is appended to the previous context, forming a longer sequence of tokens. The model uses this new, longer sequence as context when generating the next response.

Keep in mind the model is limited by a maximum of 4k tokens and that the more you feed it with tokens, the less it will be relevant.

Laegel avatar Feb 10 '23 18:02 Laegel

To expand on @Laegel 's answer, this repo's README outlines how to track a conversation in the Usage section and provides example code

LiamRM avatar Feb 14 '23 10:02 LiamRM

@gefeiyanga the following example taken from /demos section should help you: https://github.com/transitive-bullshit/chatgpt-api/blob/main/demos/demo-conversation.ts If it did, please close the issue.

hvqzao avatar Feb 16 '23 06:02 hvqzao

@gefeiyangaследующий пример, взятый из раздела /demos, должен вам помочь: https://github.com/transitive-bullshit/chatgpt-api/blob/main/demos/demo-conversation.ts Если да, закройте вопрос.

it doesn't works

msborrow avatar Feb 17 '23 16:02 msborrow

@msborrow @Tr4nt420 the default demos use an in-memory store to track previous messages. You'll need to use a persistent store to track messages using any https://github.com/jaredwray/keyv adaptor (which supports many databases). See https://github.com/transitive-bullshit/chatgpt-api/blob/main/demos/demo-conversation.ts for a working example.

OR you can use ChatGPTUnofficialProxyAPI by upgrading to v4.5.0 which automatically tracks conversations and messages on ChatGPT's servers.

transitive-bullshit avatar Feb 19 '23 08:02 transitive-bullshit