Hi,
We are working on a coding task for group conversations. With the web interface (or MacGPT), I can issue a prompt with instructions to code each line of the conversation, after which the AI will ask to insert the conversation in the text box. The AI then returns a code for each line. The trick for us is that the AI considers previous comments when generating a code. For the API, we have a number of conversations that are read from an external file. The code feeds the first conversation to the AI as a whole (with line breaks inserted at the end of each line) for the prompt to work its magic on, then feeds the second when the first is done, and so on. I’ve tried various version of this it the API but it returns just one code for the entire conversation. I’m using the ChatCompletion function with ChatGPT-3.5-turbo.
This is the relevant API code with the prompt I used in MacGPT. (The example refers to sentiment analysis to keep things simple but, ideally, it would work for different kinds of coding.) The “text” variable contains the entire conversation. Again, the problem is the routine returns one code for the entire conversation (a sample of which is below) rather than a code for each line:
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo-16k",
temperature=.5,
messages=[
{"role": "system", "content": "Please code each line in the following text for sentiment. Sentiment values should be -1 for negative, 0 for neutral, and 1 for positive. Consider the previous five lines when determining sentiment for the current line."},
{"role": "user", "content": f"Please code the following text and provide only numbers in your response... '{text}'"},
]
)
return response['choices'][0]['message']['content']
And here’s a sample conversation:
Okay. Um, I personally feel pretty strongly that he should not get, um, is it NGRI?
Mm-hmm.
Yeah.
And I think the main reason for this, this happened um, in 2011 or so, it says and he's saying that he is claiming that he, like the, that event that gave him depression was 30 years ago.
Yeah.
And it says that that lasts for about a year. And I don't think he went to bother getting help through like a psychologist or anything. And he said it was like, um, self, um, like self prescribed...
Yeah. Depression.
Depression. So I think he's kind of just looking for a easy way out.
Yeah.
Yeah.
And putting the blame on that issue.
And he's not getting the death penalty, right?
No.
No. He said...
Just life.
He told...
Yeah. Just life. Yeah.
Yeah. Yeah. No, I, I agree. I don't think he should get it either.
Yeah.
I don't think.
Yeah.
Oh, we all agree.
I think we all agree.
Yeah. But...
How long does he stay in jail for?
Life.
Life.
Life. Yeah. That's fine.
Any help would be greatly appreciated.