Skip to content

Commit fa3d81d

Browse files
marcosnavkarawoo
andauthored
chore: update chatlas environment variable references for chat-with-content and simple-shiny-chat-with-mcp (#306)
* chore: update chatlas environment variable references and version numbers for chat-with-content and simple-shiny-chat-with-mcp * Update extensions/chat-with-content/app.py Co-authored-by: Kara Woo <[email protected]> * Update extensions/simple-shiny-chat-with-mcp/app.py Co-authored-by: Kara Woo <[email protected]> --------- Co-authored-by: Kara Woo <[email protected]>
1 parent 2bf9ceb commit fa3d81d

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

extensions/chat-with-content/app.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def check_aws_bedrock_credentials():
2020
return True
2121
except Exception as e:
2222
print(
23-
f"AWS Bedrock credentials check failed and will fallback to checking for values for the CHATLAS_CHAT_PROVIDER and CHATLAS_CHAT_ARGS env vars. Err: {e}"
23+
f"AWS Bedrock credentials check failed and will fall back to checking for values for the CHATLAS_CHAT_PROVIDER_MODEL env var. Err: {e}"
2424
)
2525
return False
2626

@@ -125,16 +125,15 @@ def fetch_connect_content_list(client: connect.Client):
125125
ui.h2("LLM API", class_="setup-section-title"),
126126
ui.div(
127127
ui.HTML(
128-
"This app requires the <code>CHATLAS_CHAT_PROVIDER</code> and <code>CHATLAS_CHAT_ARGS</code> environment variables to be "
128+
"This app requires the <code>CHATLAS_CHAT_PROVIDER_MODEL</code> environment variable to be "
129129
"set along with an LLM API Key in the content access panel. Please set them in your environment before running the app. "
130130
'See the <a href="https://posit-dev.github.io/chatlas/reference/ChatAuto.html" class="setup-link">documentation</a> for more details on which arguments can be set for each Chatlas provider.'
131131
),
132132
class_="setup-description",
133133
),
134134
ui.h3("Example for OpenAI API", class_="setup-section-title"),
135135
ui.pre(
136-
"""CHATLAS_CHAT_PROVIDER = "openai"
137-
CHATLAS_CHAT_ARGS = {"model": "gpt-4o"}
136+
"""CHATLAS_CHAT_PROVIDER_MODEL = "openai/gpt-4o"
138137
OPENAI_API_KEY = "<key>" """,
139138
class_="setup-code-block",
140139
),
@@ -193,8 +192,11 @@ def fetch_connect_content_list(client: connect.Client):
193192

194193
screen_ui = ui.page_output("screen")
195194

195+
# CHATLAS_CHAT_PROVIDER and CHATLAS_CHAT_ARGS are deprecated
196+
# we still account the prescence of these for backwards compatibility.
196197
CHATLAS_CHAT_PROVIDER = os.getenv("CHATLAS_CHAT_PROVIDER")
197198
CHATLAS_CHAT_ARGS = os.getenv("CHATLAS_CHAT_ARGS")
199+
CHATLAS_CHAT_PROVIDER_MODEL = os.getenv("CHATLAS_CHAT_PROVIDER_MODEL")
198200
HAS_AWS_CREDENTIALS = check_aws_bedrock_credentials()
199201

200202

@@ -233,9 +235,9 @@ def server(input: Inputs, output: Outputs, session: Session):
233235
</important>
234236
"""
235237

236-
if CHATLAS_CHAT_PROVIDER and not HAS_AWS_CREDENTIALS:
238+
if (CHATLAS_CHAT_PROVIDER_MODEL or CHATLAS_CHAT_PROVIDER) and not HAS_AWS_CREDENTIALS:
237239
# This will pull its configuration from environment variables
238-
# CHATLAS_CHAT_PROVIDER and CHATLAS_CHAT_ARGS
240+
# CHATLAS_CHAT_PROVIDER_MODEL, or the deprecated CHATLAS_CHAT_PROVIDER and CHATLAS_CHAT_ARGS
239241
chat = ChatAuto(
240242
system_prompt=system_prompt,
241243
)
@@ -250,7 +252,7 @@ def server(input: Inputs, output: Outputs, session: Session):
250252
@render.ui
251253
def screen():
252254
if (
253-
CHATLAS_CHAT_PROVIDER is None and not HAS_AWS_CREDENTIALS
255+
CHATLAS_CHAT_PROVIDER_MODEL is None and CHATLAS_CHAT_PROVIDER is None and not HAS_AWS_CREDENTIALS
254256
) or not VISITOR_API_INTEGRATION_ENABLED:
255257
return setup_ui
256258
else:

extensions/chat-with-content/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"tags": ["llm", "shiny", "chat", "python"],
2828
"minimumConnectVersion": "2025.04.0",
2929
"requiredFeatures": ["OAuth Integrations"],
30-
"version": "0.0.2"
30+
"version": "0.0.3"
3131
},
3232
"files": {
3333
"requirements.txt": {

extensions/simple-shiny-chat-with-mcp/app.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@ def check_aws_bedrock_credentials():
2626
return True
2727
except Exception as e:
2828
print(
29-
f"AWS Bedrock credentials check failed and will fallback to checking for values for the CHATLAS_CHAT_PROVIDER and CHATLAS_CHAT_ARGS env vars. Err: {e}"
29+
f"AWS Bedrock credentials check failed and will fall back to checking for values for the CHATLAS_CHAT_PROVIDER_MODEL env var. Err: {e}"
3030
)
3131
return False
3232

3333

34+
# CHATLAS_CHAT_PROVIDER and CHATLAS_CHAT_ARGS are deprecated
35+
# we still account the prescence of these for backwards compatibility.
3436
CHATLAS_CHAT_PROVIDER = os.getenv("CHATLAS_CHAT_PROVIDER")
3537
CHATLAS_CHAT_ARGS = os.getenv("CHATLAS_CHAT_ARGS")
38+
CHATLAS_CHAT_PROVIDER_MODEL = os.getenv("CHATLAS_CHAT_PROVIDER_MODEL")
3639
HAS_AWS_BEDROCK_CREDENTIALS = check_aws_bedrock_credentials()
3740

3841
setup_ui = ui.page_fillable(
@@ -120,16 +123,15 @@ def check_aws_bedrock_credentials():
120123
ui.h2("LLM API", class_="setup-section-title"),
121124
ui.div(
122125
ui.HTML(
123-
"This app requires the <code>CHATLAS_CHAT_PROVIDER</code> and <code>CHATLAS_CHAT_ARGS</code> environment variables to be "
126+
"This app requires the <code>CHATLAS_CHAT_PROVIDER_MODEL</code> environment variable to be "
124127
"set along with an LLM API Key in the content access panel. Please set them in your environment before running the app. "
125128
'<a href="https://posit-dev.github.io/chatlas/reference/ChatAuto.html" class="setup-link">See the documentation for more details.</a>'
126129
),
127130
class_="setup-description",
128131
),
129132
ui.h3("Example for OpenAI API", class_="setup-section-title"),
130133
ui.pre(
131-
"""CHATLAS_CHAT_PROVIDER = "openai"
132-
CHATLAS_CHAT_ARGS = {"model": "gpt-4o"}
134+
"""CHATLAS_CHAT_PROVIDER_MODEL = "openai/gpt-4o"
133135
OPENAI_API_KEY = "<key>" """,
134136
class_="setup-code-block",
135137
),
@@ -234,7 +236,7 @@ def server(input: Inputs, output: Outputs, app_session: AppSession):
234236
Always show the raw output of the tools you call, and do not modify it. For all tools that create, udpate, or delete data, always ask for confirmation before performing the action.
235237
If a user's request would require multiple tool calls, create a plan of action for the user to confirm before executing those tools. The user must confirm the plan.</prime-directive>"""
236238

237-
if CHATLAS_CHAT_PROVIDER and not HAS_AWS_BEDROCK_CREDENTIALS:
239+
if (CHATLAS_CHAT_PROVIDER_MODEL or CHATLAS_CHAT_PROVIDER) and not HAS_AWS_BEDROCK_CREDENTIALS:
238240
chat = chatlas.ChatAuto(system_prompt=system_prompt)
239241

240242
if HAS_AWS_BEDROCK_CREDENTIALS:
@@ -250,7 +252,7 @@ def server(input: Inputs, output: Outputs, app_session: AppSession):
250252
@render.ui
251253
def screen():
252254
if (
253-
CHATLAS_CHAT_PROVIDER is None and not HAS_AWS_BEDROCK_CREDENTIALS
255+
CHATLAS_CHAT_PROVIDER_MODEL is None and CHATLAS_CHAT_PROVIDER is None and not HAS_AWS_BEDROCK_CREDENTIALS
254256
) or not VISITOR_API_INTEGRATION_ENABLED:
255257
return setup_ui
256258
else:

extensions/simple-shiny-chat-with-mcp/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"OAuth Integrations"
3030
],
3131
"minimumConnectVersion": "2025.04.0",
32-
"version": "0.0.3"
32+
"version": "0.0.4"
3333
},
3434
"files": {
3535
"requirements.txt": {

0 commit comments

Comments
 (0)