Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bderenzi
Copy link

@bderenzi bderenzi commented Feb 8, 2024

Thanks to @9j7axvsLuF for some sample code in the original issue #6

I had two main goals:

  1. Update to the latest versions of Claude
  2. Allow use of the system prompt (which also meant updating to use the beta messages API)

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

Thanks to @9j7axvsLuF for some sample code in the original issue tomviner#6
Comment on lines +35 to +48
# 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
Copy link
Author

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

@bderenzi
Copy link
Author

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)

@bderenzi
Copy link
Author

bderenzi commented Mar 7, 2024

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?

@Kos
Copy link

Kos commented Nov 15, 2024

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?

@bderenzi
Copy link
Author

I don't think this is maintained. Rather use:

https://github.com/simonw/llm-claude-3

@tomviner
Copy link
Owner

I don't think this is maintained. Rather use:

simonw/llm-claude-3

That's right, I'll add a note to the README

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants