Skip to content

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

Open
jvmncs wants to merge 1 commit into
tomviner:mainfrom
jvmncs:main
Open

jvmncs wants to merge 1 commit into
tomviner:mainfrom
jvmncs:main

Conversation

@jvmncs

@jvmncs jvmncs commented Mar 5, 2024

Copy link
Copy Markdown

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 thread llm_claude/__init__.py
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
Copy Markdown
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

jvmncs commented Mar 5, 2024

Copy link
Copy Markdown
Author

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

@tomviner

tomviner commented Mar 7, 2024

Copy link
Copy Markdown
Owner

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