Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# them in a file named `.env`. The `python-dotenv` package will load `.env` as
# environment variables which can be read by `os.getenv()`.
load_dotenv()
chat_model = ChatBedrockAnthropic(
chat_client = ChatBedrockAnthropic(
model="anthropic.claude-3-sonnet-20240229-v1:0",
)

Expand All @@ -32,5 +32,5 @@
# Define a callback to run when the user submits a message
@chat.on_user_submit
async def handle_user_input(user_input: str):
response = await chat_model.stream_async(user_input)
response = await chat_client.stream_async(user_input)
await chat.append_message_stream(response)
4 changes: 2 additions & 2 deletions shiny/templates/chat/llm-enterprise/azure-openai/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the docs for more information on how to obtain one.
# https://posit-dev.github.io/chatlas/reference/ChatAzureOpenAI.html
load_dotenv()
chat_model = ChatAzureOpenAI(
chat_client = ChatAzureOpenAI(
api_key=os.getenv("AZURE_OPENAI_API_KEY"),
endpoint="https://my-endpoint.openai.azure.com",
deployment_id="gpt-4o-mini",
Expand All @@ -37,5 +37,5 @@
# Define a callback to run when the user submits a message
@chat.on_user_submit
async def handle_user_input(user_input: str):
response = await chat_model.stream_async(user_input)
response = await chat_client.stream_async(user_input)
await chat.append_message_stream(response)
4 changes: 2 additions & 2 deletions shiny/templates/chat/llms/anthropic/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the docs for more information on how to obtain one.
# https://posit-dev.github.io/chatlas/reference/ChatAnthropic.html
load_dotenv()
chat_model = ChatAnthropic(
chat_client = ChatAnthropic(
api_key=os.environ.get("ANTHROPIC_API_KEY"),
model="claude-3-7-sonnet-latest",
system_prompt="You are a helpful assistant.",
Expand All @@ -37,5 +37,5 @@
# Generate a response when the user submits a message
@chat.on_user_submit
async def handle_user_input(user_input: str):
response = await chat_model.stream_async(user_input)
response = await chat_client.stream_async(user_input)
await chat.append_message_stream(response)
4 changes: 2 additions & 2 deletions shiny/templates/chat/llms/google/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the docs for more information on how to obtain one.
# https://posit-dev.github.io/chatlas/reference/ChatGoogle.html
load_dotenv()
chat_model = ChatGoogle(
chat_client = ChatGoogle(
api_key=os.environ.get("GOOGLE_API_KEY"),
system_prompt="You are a helpful assistant.",
model="gemini-2.0-flash",
Expand All @@ -33,5 +33,5 @@
# Generate a response when the user submits a message
@chat.on_user_submit
async def handle_user_input(user_input: str):
response = await chat_model.stream_async(user_input)
response = await chat_client.stream_async(user_input)
await chat.append_message_stream(response)
4 changes: 2 additions & 2 deletions shiny/templates/chat/llms/langchain/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# app, or set them in a file named `.env`. The `python-dotenv` package will load `.env`
# as environment variables which can later be read by `os.getenv()`.
load_dotenv()
chat_model = ChatOpenAI(
chat_client = ChatOpenAI(
api_key=os.environ.get("OPENAI_API_KEY"),
model="gpt-4o",
)
Expand All @@ -38,5 +38,5 @@
# Define a callback to run when the user submits a message
@chat.on_user_submit
async def handle_user_input(user_input: str):
response = await chat_model.stream_async(user_input)
response = await chat_client.stream_async(user_input)
await chat.append_message_stream(response)
4 changes: 2 additions & 2 deletions shiny/templates/chat/llms/ollama/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# ChatOllama() requires an Ollama model server to be running locally.
# See the docs for more information on how to set up a local Ollama server.
# https://posit-dev.github.io/chatlas/reference/ChatOllama.html
chat_model = ChatOllama(model="llama3.2")
chat_client = ChatOllama(model="llama3.2")

# Set some Shiny page options
ui.page_opts(
Expand All @@ -29,5 +29,5 @@
# Generate a response when the user submits a message
@chat.on_user_submit
async def handle_user_input(user_input: str):
response = await chat_model.stream_async(user_input)
response = await chat_client.stream_async(user_input)
await chat.append_message_stream(response)
4 changes: 2 additions & 2 deletions shiny/templates/chat/llms/openai/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the docs for more information on how to obtain one.
# https://posit-dev.github.io/chatlas/reference/ChatOpenAI.html
load_dotenv()
chat_model = ChatOpenAI(
chat_client = ChatOpenAI(
api_key=os.environ.get("OPENAI_API_KEY"),
model="gpt-4o",
system_prompt="You are a helpful assistant.",
Expand All @@ -37,5 +37,5 @@
# Generate a response when the user submits a message
@chat.on_user_submit
async def handle_user_input(user_input: str):
response = await chat_model.stream_async(user_input)
response = await chat_client.stream_async(user_input)
await chat.append_message_stream(response)
8 changes: 4 additions & 4 deletions shiny/templates/chat/llms/playground/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ def get_model():
}

if input.model() in models["openai"]:
chat_model = ctl.ChatOpenAI(**model_params)
chat_client = ctl.ChatOpenAI(**model_params)
elif input.model() in models["claude"]:
chat_model = ctl.ChatAnthropic(**model_params)
chat_client = ctl.ChatAnthropic(**model_params)
elif input.model() in models["google"]:
chat_model = ctl.ChatGoogle(**model_params)
chat_client = ctl.ChatGoogle(**model_params)
else:
raise ValueError(f"Invalid model: {input.model()}")

return chat_model
return chat_client


@reactive.calc
Expand Down
Loading