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 Mistral Integration page #121

Closed
1 task done
TuanaCelik opened this issue Jan 12, 2024 · 3 comments
Closed
1 task done

Add Mistral Integration page #121

TuanaCelik opened this issue Jan 12, 2024 · 3 comments
Assignees

Comments

@TuanaCelik
Copy link
Member

TuanaCelik commented Jan 12, 2024

Currently, Mistral AI is supported via the OpenAIGenerator simply by providing the right model and API key. Let's add an integration page for Mistral which is slightly different to the rest:

  • Explain that it's a guide on how to use OpenAIGenerator to make use of Mistral

We can explore adding full functionality as a separate integration next, and change the content of the integration tile accordingly.

Tasks

  1. annthurium
@anakin87
Copy link
Member

This works:

from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.dataclasses import ChatMessage

api_key = "MISTRAL-API-KEY"
model = "mistral-medium"

client = OpenAIChatGenerator(
    api_key=api_key, model_name=model, api_base_url="https://api.mistral.ai/v1"
)

response = client.run(
    messages=[ChatMessage.from_user("What is the best French cheese?")]
)
print(response)

@anakin87
Copy link
Member

Embedders

from haystack.components.embedders import OpenAITextEmbedder

api_key = "MISTRAL-API-KEY"
model = "mistral-embed"

embedder = OpenAITextEmbedder(api_key=api_key, model_name=model, api_base_url="https://api.mistral.ai/v1")

response = embedder.run(text="What is the best French cheese?")
print(response)
# {'embedding': [-0.0186004638671875, ...],
# 'meta': {'model': 'mistral-embed', 
#'usage': {'prompt_tokens': 9, 'total_tokens': 9, 'completion_tokens': 0}}}

@annthurium
Copy link
Contributor

#125

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

No branches or pull requests

3 participants