From 6a48450a60f205eb1387b78c06d454ac02e7f7d7 Mon Sep 17 00:00:00 2001 From: Andrew Huang Date: Fri, 4 Oct 2024 16:36:36 -0700 Subject: [PATCH] lint --- docs/examples/kickstart_snippets/mistralai_.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/examples/kickstart_snippets/mistralai_.py b/docs/examples/kickstart_snippets/mistralai_.py index 02d5399..6451a4a 100644 --- a/docs/examples/kickstart_snippets/mistralai_.py +++ b/docs/examples/kickstart_snippets/mistralai_.py @@ -9,18 +9,23 @@ - Uses `yield` to continuously concatenate the parts of the response. """ +import os + import panel as pn from mistralai import Mistral, UserMessage -import os pn.extension() + def update_api_key(api_key): # Use the provided api_key or default to the environment variable pn.state.cache["aclient"] = ( - Mistral(api_key=api_key) if api_key else Mistral(api_key=os.getenv("MISTRAL_API_KEY", "")) + Mistral(api_key=api_key) + if api_key + else Mistral(api_key=os.getenv("MISTRAL_API_KEY", "")) ) + async def callback(contents: str, user: str, instance: pn.chat.ChatInterface): # memory is a list of serialized messages messages = instance.serialize() @@ -40,6 +45,7 @@ async def callback(contents: str, user: str, instance: pn.chat.ChatInterface): message += part yield message + # Input widget for the API key api_key_input = pn.widgets.PasswordInput( placeholder="Uses $MISTRAL_API_KEY if not set",