Skip to content

Commit 5134b19

Browse files
committed
Encourage async in response generation
1 parent ee1a47e commit 5134b19

File tree

7 files changed

+7
-7
lines changed

7 files changed

+7
-7
lines changed

shiny/templates/chat/llm-enterprise/aws-bedrock-anthropic/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@
3636
# Define a callback to run when the user submits a message
3737
@chat.on_user_submit
3838
async def handle_user_input(user_input: str):
39-
response = chat_model.stream(user_input)
39+
response = await chat_model.stream_async(user_input)
4040
await chat.append_message_stream(response)

shiny/templates/chat/llm-enterprise/azure-openai/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@
3737
# Define a callback to run when the user submits a message
3838
@chat.on_user_submit
3939
async def handle_user_input(user_input: str):
40-
response = chat_model.stream(user_input)
40+
response = await chat_model.stream_async(user_input)
4141
await chat.append_message_stream(response)

shiny/templates/chat/llms/anthropic/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@
3737
# Generate a response when the user submits a message
3838
@chat.on_user_submit
3939
async def handle_user_input(user_input: str):
40-
response = chat_model.stream(user_input)
40+
response = await chat_model.stream_async(user_input)
4141
await chat.append_message_stream(response)

shiny/templates/chat/llms/google/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@
3333
# Generate a response when the user submits a message
3434
@chat.on_user_submit
3535
async def handle_user_input(user_input: str):
36-
response = chat_model.stream(user_input)
36+
response = await chat_model.stream_async(user_input)
3737
await chat.append_message_stream(response)

shiny/templates/chat/llms/langchain/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@
3838
# Define a callback to run when the user submits a message
3939
@chat.on_user_submit
4040
async def handle_user_input(user_input: str):
41-
response = chat_model.stream(user_input)
41+
response = await chat_model.stream_async(user_input)
4242
await chat.append_message_stream(response)

shiny/templates/chat/llms/ollama/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@
2929
# Generate a response when the user submits a message
3030
@chat.on_user_submit
3131
async def handle_user_input(user_input: str):
32-
response = chat_model.stream(user_input)
32+
response = await chat_model.stream_async(user_input)
3333
await chat.append_message_stream(response)

shiny/templates/chat/llms/openai/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@
3737
# Generate a response when the user submits a message
3838
@chat.on_user_submit
3939
async def handle_user_input(user_input: str):
40-
response = chat_model.stream(user_input)
40+
response = await chat_model.stream_async(user_input)
4141
await chat.append_message_stream(response)

0 commit comments

Comments
 (0)