Reputation: 944
Afaik, there're two ways of interacting with text OpenAI api now: completions and chat. I want to build this:
Is it possible to achieve somehow? Thank you.
Upvotes: 0
Views: 62
Reputation: 20127
I'd suggest using the Chat interface. You can't set roles for multiple users yet, but send the model something like this:
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "Say something if you detect a pattern in the user messages. Otherwise say nothing."},
{"role": "user", "content": "User1: I'm in charge."},
{"role": "user", "content": "User2: I'mway inway hargecay."},
{"role": "user", "content": "User1: stop repeating me"},
{"role": "user", "content": "User2: opstay epeatingray emay."}
]
)
print(response.choices[0].message.content)
% python foo.py
User1 and User2 are both speaking in Pig Latin.
Upvotes: 1