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

refactor plugin to use Messages API, add nextgen claude models #8

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

Conversation

jvmncs
Copy link

@jvmncs jvmncs commented Mar 5, 2024

updates the plugin to use the next generation of claude models. since the newer generation requires usage of anthropic's Messages API (very similar to openai's, but not exact), I migrated the plugin to use that instead of the older completions api that it was based on

Comment on lines +95 to +100
if hasattr(comp, "content_block"):
response = comp.content_block.text
yield response
elif hasattr(comp, "delta"):
if hasattr(comp.delta, "text"):
yield comp.delta.text
Copy link
Author

Choose a reason for hiding this comment

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

this block of code is pretty fast and loose, based on their documented SSE format here. I mostly just inspected the python objects coming out of the completion stream and used this to get the raw text deltas. there's probably a more principled way to do it, happy to rewrite if that's a concern

@jvmncs
Copy link
Author

jvmncs commented Mar 5, 2024

sorry, didn't even realize the older PR was still open! happy to close this in favor of that if it's preferred

@tomviner
Copy link
Owner

tomviner commented Mar 7, 2024

Thanks for this @jvmncs I'll look to get this or something like it released in the next couple days

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