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

add anthropic messages support and stream #118

Merged
merged 5 commits into from
Mar 15, 2024

Conversation

wenzhe-log10
Copy link
Collaborator

Support Anthropic Claude-3

@wenzhe-log10 wenzhe-log10 requested review from nqn and kxtran March 13, 2024 23:14
@@ -214,9 +214,14 @@ async def log_async(completion_url, func, **kwargs):
if "messages" in kwargs:
kwargs["messages"] = flatten_messages(kwargs["messages"])

if "anthropic" in func.__module__:
if "system" in kwargs:
kwargs["messages"].insert(0, {"role": "system", "content": kwargs["system"]})
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

anthropic messages func has a system arg to pass system messages. This put the message into messages like openai chat API.

log_row = {
# do we want to also store args?
"status": "started",
"kind": "chat" if "chat" in func.__module__ or "messages" in func.__module__ else "completion",
Copy link
Collaborator Author

@wenzhe-log10 wenzhe-log10 Mar 13, 2024

Choose a reason for hiding this comment

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

[bug fix] seems completions needs kind to render in GUI. So set it when post the request. Otherwise, the completions only shows after response (with kind set) posted.

@wenzhe-log10 wenzhe-log10 force-pushed the wenzhe/anthropic_messages branch from c1b8eac to 395f76e Compare March 13, 2024 23:45
@wenzhe-log10 wenzhe-log10 merged commit 1b7b4ef into main Mar 15, 2024
1 check passed
@wenzhe-log10 wenzhe-log10 deleted the wenzhe/anthropic_messages branch March 15, 2024 21:26
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