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 support for Anthropic models #760

Merged
merged 5 commits into from
May 26, 2024

Conversation

sabaimran
Copy link
Member

@sabaimran sabaimran commented May 26, 2024

Incoming

Long-time coming, add first-party support for using Anthropic models inside the Khoj codebase. I went with a first-party approach (instead of leveraging an OpenAI-API compatible server, for instance) because the Anthropic models have slight nuances in the way messages are handled. For example, the first message to the model always has to be a user message. It is also less good at honoring the prompt output format when it's intended to be JSON.

Closes #760

sabaimran added 3 commits May 26, 2024 04:38
- Had to use a custom class because there was enough nuance with how the anthropic SDK works that it would be better to simply separate out the logic. The extract questions flow needed modification of the system prompt in order to work as intended with the haiku model
@sabaimran sabaimran requested a review from debanjum May 26, 2024 12:36
@sabaimran sabaimran force-pushed the features/integrate-anthropic-claude branch from cd3fb4d to 0e43157 Compare May 26, 2024 13:11
@sabaimran sabaimran merged commit 01cdc54 into master May 26, 2024
7 checks passed
@sabaimran sabaimran deleted the features/integrate-anthropic-claude branch May 26, 2024 17:20
@@ -542,8 +561,7 @@ def send_message_to_model_wrapper_sync(
)

elif conversation_config.model_type == "openai":
openai_chat_config = ConversationAdapters.get_openai_conversation_config()
api_key = openai_chat_config.api_key
api_key = conversation_config.openai_config.api_key
Copy link
Member

Choose a reason for hiding this comment

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

Should we rename openai_config to something more generic, e.g online_model?

Suggested change
api_key = conversation_config.openai_config.api_key
api_key = conversation_config.online_model.api_key

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