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 Anthropic messages API #304

Merged
merged 2 commits into from
Mar 22, 2024
Merged

Conversation

janimo
Copy link
Contributor

@janimo janimo commented Mar 15, 2024

This switches to the newer Anthropic API. The claude-3 models only work with this (so do claude-2.1 and claude-instant-1.2)

https://docs.anthropic.com/claude/reference/migrating-from-text-completions-to-messages

@merrymercy
Copy link
Contributor

merrymercy commented Mar 22, 2024

@janimo Great! Can you also add some if/else to make it also work with old versions or enforce a new version here?

anthropic = ["anthropic", "numpy"]

@janimo
Copy link
Contributor Author

janimo commented Mar 22, 2024

@merrymercy thanks for the review. Updated the package version required. The only model that does not work with the new API is the legacy Claude 2.

@@ -19,7 +19,7 @@ def few_shot_qa(s, question):
\n\nAssistant: Rome
""")
s += "\n\nHuman: " + question + "\n"
s += "\n\nAssistant:" + sgl.gen("answer", stop="\n", temperature=0)
s += "\n\nAssistant:" + sgl.gen("answer", stop="\\n", temperature=0)
Copy link
Contributor

@merrymercy merrymercy Mar 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is "\\n" a typo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the new API apparently does not take empty stop sequences, and considers '\n' empty....

@merrymercy merrymercy merged commit e57f079 into sgl-project:main Mar 22, 2024
@janimo janimo deleted the anthropic-new-api branch September 17, 2024 12:28
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.

2 participants