Skip to content

Commit ed6cae6

Browse files
authored
Miscellaneous Chat template improvements (#1872)
1 parent 3fe8c64 commit ed6cae6

35 files changed

+220
-77
lines changed
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
{
22
"type": "app",
33
"id": "chat-ai-anthropic-aws",
4-
"title": "Chat AI using Anthropic via AWS Bedrock"
4+
"title": "Chat AI using Anthropic via AWS Bedrock",
5+
"next_steps": [
6+
"Put your Bedrock credentials in the `template.env` file and rename it to `.env`.",
7+
"Run the app with `shiny run app.py`."
8+
],
9+
"follow_up": [
10+
{
11+
"type": "info",
12+
"text": "Need help connecting to Bedrock?"
13+
},
14+
{
15+
"type": "action",
16+
"text": "Learn more at https://posit-dev.github.io/chatlas/reference/ChatBedrockAnthropic.html"
17+
}
18+
]
519
}

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
load_dotenv()
1616
chat_model = ChatBedrockAnthropic(
1717
model="anthropic.claude-3-sonnet-20240229-v1:0",
18-
# aws_secret_key=os.getenv("AWS_SECRET_KEY"),
19-
# aws_access_key=os.getenv("AWS_ACCESS_KEY"),
20-
# aws_region=os.getenv("AWS_REGION"),
21-
# aws_account_id=os.getenv("AWS_ACCOUNT_ID"),
2218
)
2319

2420
# Set some Shiny page options
@@ -36,5 +32,5 @@
3632
# Define a callback to run when the user submits a message
3733
@chat.on_user_submit
3834
async def handle_user_input(user_input: str):
39-
response = chat_model.stream(user_input)
35+
response = await chat_model.stream_async(user_input)
4036
await chat.append_message_stream(response)
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
shiny
22
python-dotenv
3-
tokenizers
43
chatlas
54
anthropic[bedrock]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Once you provided your API key, rename this file to .env
2+
# The load_dotenv() in the app.py will then load this env variable
3+
AWS_SECRET_KEY=<Your AWS info here>
4+
AWS_ACCESS_KEY=<Your AWS info here>
5+
AWS_REGION=<Your AWS info here>
6+
AWS_ACCOUNT_ID=<Your AWS info here>
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
{
22
"type": "app",
33
"id": "chat-ai-azure-openai",
4-
"title": "Chat AI using OpenAI via Azure"
4+
"title": "Chat AI using OpenAI via Azure",
5+
"next_steps": [
6+
"Put your Azure credentials in the `template.env` file and rename it to `.env`.",
7+
"Run the app with `shiny run app.py`."
8+
],
9+
"follow_up": [
10+
{
11+
"type": "info",
12+
"text": "Need help connecting to Azure?"
13+
},
14+
{
15+
"type": "action",
16+
"text": "Learn more at https://posit-dev.github.io/chatlas/reference/ChatAzureOpenAI.html"
17+
}
18+
]
519
}

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)
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
shiny
22
python-dotenv
3-
tokenizers
43
chatlas
54
openai
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Once you provided your API key, rename this file to .env
2+
# The load_dotenv() in the app.py will then load this env variable
3+
AZURE_OPENAI_API_KEY=<Your Azure OpenAI API key>
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
{
22
"type": "app",
33
"id": "chat-ai-anthropic",
4-
"title": "Chat AI using Anthropic"
4+
"title": "Chat AI using Anthropic",
5+
"next_steps": [
6+
"Put your Anthropic API key in the `template.env` file and rename it to `.env`.",
7+
"Run the app with `shiny run app.py`."
8+
],
9+
"follow_up": [
10+
{
11+
"type": "info",
12+
"text": "Need help obtaining an API key?"
13+
},
14+
{
15+
"type": "action",
16+
"text": "Learn how to obtain one at https://posit-dev.github.io/chatlas/reference/ChatAnthropic.html"
17+
}
18+
]
519
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
load_dotenv()
1515
chat_model = ChatAnthropic(
1616
api_key=os.environ.get("ANTHROPIC_API_KEY"),
17-
model="claude-3-5-sonnet-latest",
17+
model="claude-3-7-sonnet-latest",
1818
system_prompt="You are a helpful assistant.",
1919
)
2020

@@ -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)