#Implement question/answering on a piece of text using chat API

1 messages · Page 1 of 1 (latest)

molten kettle
#

I've been trying to figure this out for a minute now, any tips appreciated:

I want to send in some text to the Chat API and sequentially ask it questions and get answers to those questions one by one. I don't want to create a new input prompt each time to ask a new question on the same text which would use context tokens for the same text each time.

I'm currently submitting all questions in the prompt and asking it to end each answer with two line breaks so I can break up the responses to each question. But I'm sure there's a better way to do it.

     for question in questions:
         messages.append({"role": "user", "content": question})

     chat_response = client.chat.completions.create(
         model="gpt-3.5-turbo-1106",
         messages=messages,
     )
     full_response = chat_response.choices[0].message.content

     # Split the response into parts based on '\n\n'
     response_parts = full_response.split('\n\n')


     summary = response_parts[0]
     category = response_parts[1]
     background = response_parts[2]
     claims = response_parts[3]
     stakeholders = response_parts[4]
     impact = response_parts[5]

lusty warren
#

What exactly are you trying to do