Description
Description
MistralAI supports custom structured output. It would be useful to also implement it in neo4j-graphrag. How to use it with mistralai python package:
import os
from mistralai.client import Mistral
from pydantic import BaseModel
api_key = os.environ["MISTRAL_API_KEY"]
model = "ministral-8b-latest"
client = Mistral(api_key=api_key)
class Book(BaseModel):
name: str
authors: list[str]
chat_response = client.chat.parse(
model=model,
messages=[
{
"role": "system",
"content": "Extract the books information."
},
{
"role": "user",
"content": "I recently read 'To Kill a Mockingbird' by Harper Lee."
},
],
response_format=Book,
max_tokens=256,
temperature=0
)
print(chat_response.choices[0].message.content) // for JSON output
print(chat_response.choices[0].message.parsed) // for Pydantic model output
Additional Info
No response
Description
Description
MistralAI supports custom structured output. It would be useful to also implement it in neo4j-graphrag. How to use it with
mistralaipython package:Additional Info
No response