transitive-bullshit / chatgpt-api

Node.js client for the official ChatGPT API. 🔥

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to send last 5 message by user_id ?

mtariqsajid opened this issue · comments

Describe the feature

I want to know is there a way to send last 5 message of the user in sendMessage method

let options: any = {
   completionParams: {
      model: openAIModelDB,
      messages: [{
            role: 'user',
            content: 'when obama was born'
         },
         {
            role: 'assistant',
            content: 'Barack Obama was born on August 4, 1961.'
         },
         {
            role: 'user',
            content: 'when obama was born'
         },
         {
            role: 'assistant',
            content: 'Barack Obama was born on August 4, 1961.'
         }
      ]
   }
};

   options.completionParams = {
      ...options.completionParams,
      stop: data?.stopSequences,
      temperature: data?.temperature,
      top_p: data?.topP,
      presence_penalty: data?.presencePenalty,
      frequency_penalty: data?.frequencyPenalty,
   };

const res = await ChatGpt.ChatGPTClient.sendMessage(message, options);

right now Messages are omit in sendMessage method

what i am trying to do is create a chat message like chatgpt and i want to get all message by user id then send last 5 message to chatgpt right now we can only send last message parent id to chatgpt. and parent message is change every time new message is return is there is a possibility to keep parent message id same but change the chat message id

anyone help me here @transitive-bullshit

maybe this pr can help you.