-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use messages API and system prompt #7
base: main
Are you sure you want to change the base?
Conversation
Thanks to @9j7axvsLuF for some sample code in the original issue tomviner#6
# Generate a list of message dictionaries based on conversation history | ||
messages = [] | ||
current_system = None | ||
if conversation is not None: | ||
for prev_response in conversation.responses: | ||
if (prev_response.prompt.system and prev_response.prompt.system != current_system): | ||
current_system = prev_response.prompt.system | ||
messages.append({"role": "user", "content": prev_response.prompt.prompt}) | ||
messages.append({"role": "assistant", "content": prev_response.text()}) | ||
if prompt.system and prompt.system != current_system: | ||
current_system = prompt.system | ||
messages.append({"role": "user", "content": prompt.prompt}) | ||
|
||
return messages, current_system |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed Simon's OpenAI plugin here. I don't think Anthropic allows mid-conversation system
prompts, so I went with the most recent system
prompt overriding everything else. I could imagine other behaviour, including generating some warning to the user if there are multiple system prompts
Just wanted to give a small bump here since about a week ago Anthropic announced that their messages API is out of beta. (No particular rush on this from our end in that we're fine to use our fork) |
Just flagging that this PR is now out of date since Anthropic has released v3 of their models. I can make another PR once they release haiku, though seems like this repo is deprioritized? |
Just found this PR while trying to add new models on my own (v3 and v3.5). Looks like Claude discontinued claude-1-instant, while claude-2 still works. @tomviner how's things from your end, are you accepting PRs? |
I don't think this is maintained. Rather use: |
That's right, I'll add a note to the README |
Thanks to @9j7axvsLuF for some sample code in the original issue #6
I had two main goals:
I didn't use the code from @9j7axvsLuF verbatim because I found that it broke the API. A tertiary goal I discovered I had was to maintain the API so that I could swap between models seamlessly. I'm not too in the weeds here, but can we create a conversation object to prime the conversation and "put words in Claude's mouth"?
Apologies it's all lumped in one big commit/PR, but it's a pretty small update overall