Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /Chainlit_chainlit /cypress /e2e /config_overrides /main.py
| import os | |
| from typing import Optional | |
| import chainlit as cl | |
| from chainlit.config import ( | |
| ChainlitConfigOverrides, | |
| FeaturesSettings, | |
| McpFeature, | |
| SseMcpServer, | |
| UISettings, | |
| ) | |
| os.environ["CHAINLIT_AUTH_SECRET"] = "SUPER_SECRET" # nosec B105 | |
| starters = [ | |
| cl.Starter( | |
| label="Default Chat", | |
| message="Start a conversation with default settings", | |
| icon="https://picsum.photos/300", | |
| ), | |
| cl.Starter( | |
| label="MCP Test", | |
| message="Test MCP functionality", | |
| icon="https://picsum.photos/350", | |
| ), | |
| ] | |
| async def chat_profile(current_user: cl.User): | |
| if current_user.metadata["role"] != "ADMIN": | |
| return None | |
| return [ | |
| cl.ChatProfile( | |
| name="Default Profile", | |
| icon="https://picsum.photos/250", | |
| markdown_description="Standard profile without MCP features. This profile uses **default settings** without any special configurations.", | |
| starters=starters, | |
| ), | |
| cl.ChatProfile( | |
| name="MCP Enabled", | |
| markdown_description="Profile with **MCP features enabled**. This profile has *Model Context Protocol* support activated. [Learn more](https://example.com/mcp)", | |
| icon="https://picsum.photos/250", | |
| starters=starters, | |
| config_overrides=ChainlitConfigOverrides( | |
| ui=UISettings(name="MCP UI"), | |
| features=FeaturesSettings( | |
| mcp=McpFeature( | |
| enabled=True, | |
| servers=[ | |
| SseMcpServer( | |
| type="sse", | |
| name="example-sse", | |
| url="https://mcp.example.com/sse", | |
| ) | |
| ], | |
| ) | |
| ), | |
| ), | |
| ), | |
| cl.ChatProfile( | |
| name="MCP Disabled", | |
| markdown_description="Profile with **MCP explicitly disabled**. This ensures no MCP functionality is available.", | |
| icon="https://picsum.photos/200", | |
| starters=starters, | |
| config_overrides=ChainlitConfigOverrides( | |
| features=FeaturesSettings(mcp=McpFeature(enabled=False)) | |
| ), | |
| ), | |
| ] | |
| def auth_callback(username: str, password: str) -> Optional[cl.User]: | |
| if (username, password) == ("admin", "admin"): | |
| return cl.User(identifier="admin", metadata={"role": "ADMIN"}) | |
| else: | |
| return None | |
| async def on_message(): | |
| user = cl.user_session.get("user") | |
| chat_profile = cl.user_session.get("chat_profile") | |
| await cl.Message( | |
| content=f"starting chat with {user.identifier} using the {chat_profile} chat profile" | |
| ).send() | |
Xet Storage Details
- Size:
- 2.84 kB
- Xet hash:
- 580ba07ddb15a7e2f9e6de26fc96197afc0d224418aa8675d2e565aa4c5487ab
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.