OpenAI API - Handling different prompts but same context with a fined tuned model

Let’s say you have this use case :
fine tuned model that has those type of questions and will return a json file :
{“prompt”: “What do we know about X ?”, “completion”: “{\"objectType\" : \"contact or company\",\"data\" : \"XXXXX\"} END”}
{“prompt”: “When did we meet with X?”, “completion”: “{\"objectType\" : \"contact or company\",\"data\" : \"XXXXX\"} END”}

If I ask straight forward questions, I get my answers from the API correctly, but If I try to create interaction between the prompts, I don’t get what I’m expected.

Prompt 1: Do we know this person/company ?
API (based on finetuning) : Will return the company/person profile json data
Prompt 2 : Did we we meet with them ?
API (based on finetuning or base model): Should know that we are still talking about the company before but we are requesting different information this time
Prompt 3 : Same question, but for company Y ?
API (based on finetuning or base model): Should know that we are talking about the same context before but the subject type has changed.

ChatGPT can handle that, just wondering how to do it with the API (without sending the whole history as context - we don’t want client data to go to OpenAI) or adjusted parameters

const response = await this.openai.createCompletion({
               model: 'curie:ft-ZZZ-2023-08-28-14-15-55',
               prompt: query,
               temperature: 0,
               max_tokens: 60,
               frequency_penalty: 0,
               presence_penalty: 0.6,
               stop: ['END']

Thank you!

Hey @interino, it sounds like you want to use the update chat completions API along with the new /v1/fine_tuning/jobs API. The prompt / completion pair setup will not work well for the use case you are going after here.

1 Like

If you want answering capability about knowledge, the AI needs to have that knowledge.

Hi @logankilpatrick , thanks for the quick response!
I’ve read the link you sent me and if I’ve understood well I should update my dataset to look like this format

{"messages": [{"role": "system", "content": "Marv is a business assistant, you provide information about companies and people"}, {"role": "user", "content": "What do we know about company X ?"}, {"role": "assistant", "content": "{json data}"}]}

my node js call will remain the same ? How the chatbot is going to keep the context between the requests ?

If you want multi-turn conversations where the AI is aware of previous chat, your software must remember those prior conversations of the user’s session and pass them again before the latest question. And then manage so the chat doesn’t get too long.

Here is a code example in a forum topic on the same question:

and an easier to understand python example I wrote for forum instruction:

Thanks a lot!
I’ll give it a try and let you know my progress!