sumedhphadke commited on
Commit
9ecf75b
ยท
1 Parent(s): a651d37

changed chainlit config

Browse files
Files changed (5) hide show
  1. .chainlit/config.toml +160 -0
  2. .gitignore +2 -1
  3. Dockerfile +3 -2
  4. app.py +30 -10
  5. chainlit.md +3 -12
.chainlit/config.toml ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ # List of environment variables to be provided by each user to use the app.
3
+ user_env = []
4
+
5
+ # Duration (in seconds) during which the session is saved when the connection is lost
6
+ session_timeout = 3600
7
+
8
+ # Duration (in seconds) of the user session expiry
9
+ user_session_timeout = 1296000 # 15 days
10
+
11
+ # Enable third parties caching (e.g., LangChain cache)
12
+ cache = false
13
+
14
+ # Whether to persist user environment variables (API keys) to the database
15
+ # Set to true to store user env vars in DB, false to exclude them for security
16
+ persist_user_env = false
17
+
18
+ # Whether to mask user environment variables (API keys) in the UI with password type
19
+ # Set to true to show API keys as ***, false to show them as plain text
20
+ mask_user_env = false
21
+
22
+ # Authorized origins
23
+ allow_origins = ["*"]
24
+
25
+ [features]
26
+ # Process and display HTML in messages. This can be a security risk (see https://stackoverflow.com/questions/19603097/why-is-it-dangerous-to-render-user-generated-html-or-javascript)
27
+ unsafe_allow_html = false
28
+
29
+ # Process and display mathematical expressions. This can clash with "$" characters in messages.
30
+ latex = false
31
+
32
+ # Autoscroll new user messages at the top of the window
33
+ user_message_autoscroll = true
34
+
35
+ # Autoscroll new assistant messages
36
+ assistant_message_autoscroll = true
37
+
38
+ # Automatically tag threads with the current chat profile (if a chat profile is used)
39
+ auto_tag_thread = true
40
+
41
+ # Allow users to edit their own messages
42
+ edit_message = true
43
+
44
+ # Allow users to share threads (backend + UI). Requires an app-defined on_shared_thread_view callback.
45
+ allow_thread_sharing = false
46
+
47
+ [features.slack]
48
+ # Add emoji reaction when message is received (requires reactions:write OAuth scope)
49
+ reaction_on_message_received = false
50
+
51
+ # Authorize users to spontaneously upload files with messages
52
+ [features.spontaneous_file_upload]
53
+ enabled = true
54
+ # Define accepted file types using MIME types
55
+ # Examples:
56
+ # 1. For specific file types:
57
+ # accept = ["image/jpeg", "image/png", "application/pdf"]
58
+ # 2. For all files of certain type:
59
+ # accept = ["image/*", "audio/*", "video/*"]
60
+ # 3. For specific file extensions:
61
+ # accept = { "application/octet-stream" = [".xyz", ".pdb"] }
62
+ # Note: Using "*/*" is not recommended as it may cause browser warnings
63
+ accept = ["*/*"]
64
+ max_files = 20
65
+ max_size_mb = 500
66
+
67
+ [features.audio]
68
+ # Enable audio features
69
+ enabled = false
70
+ # Sample rate of the audio
71
+ sample_rate = 24000
72
+
73
+ [features.mcp]
74
+ # Enable Model Context Protocol (MCP) features
75
+ enabled = false
76
+
77
+ [features.mcp.sse]
78
+ enabled = true
79
+
80
+ [features.mcp.streamable-http]
81
+ enabled = true
82
+
83
+ [features.mcp.stdio]
84
+ enabled = true
85
+ # Only the executables in the allow list can be used for MCP stdio server.
86
+ # Only need the base name of the executable, e.g. "npx", not "/usr/bin/npx".
87
+ # Please don't comment this line for now, we need it to parse the executable name.
88
+ allowed_executables = ["npx", "uvx"]
89
+
90
+ [UI]
91
+ # Name of the assistant.
92
+ name = "Design Thinking Coach"
93
+
94
+ # default_theme = "dark"
95
+
96
+ # Force a specific language for all users (e.g., "en-US", "he-IL", "fr-FR")
97
+ # If not set, the browser's language will be used
98
+ # language = "en-US"
99
+
100
+ # layout = "wide"
101
+
102
+ # default_sidebar_state = "open"
103
+
104
+ # Description of the assistant. This is used for HTML tags.
105
+ # description = ""
106
+
107
+ # Chain of Thought (CoT) display mode. Can be "hidden", "tool_call" or "full".
108
+ cot = "full"
109
+
110
+ # Specify a CSS file that can be used to customize the user interface.
111
+ # The CSS file can be served from the public directory or via an external link.
112
+ # custom_css = "/public/test.css"
113
+
114
+ # Specify additional attributes for a custom CSS file
115
+ # custom_css_attributes = "media=\"print\""
116
+
117
+ # Specify a JavaScript file that can be used to customize the user interface.
118
+ # The JavaScript file can be served from the public directory.
119
+ # custom_js = "/public/test.js"
120
+
121
+ # The style of alert boxes. Can be "classic" or "modern".
122
+ alert_style = "classic"
123
+
124
+ # Specify additional attributes for custom JS file
125
+ # custom_js_attributes = "async type = \"module\""
126
+
127
+ # Custom login page image, relative to public directory or external URL
128
+ # login_page_image = "/public/custom-background.jpg"
129
+
130
+ # Custom login page image filter (Tailwind internal filters, no dark/light variants)
131
+ # login_page_image_filter = "brightness-50 grayscale"
132
+ # login_page_image_dark_filter = "contrast-200 blur-sm"
133
+
134
+ # Specify a custom meta URL (used for meta tags like og:url)
135
+ # custom_meta_url = "https://github.com/Chainlit/chainlit"
136
+
137
+ # Specify a custom meta image url.
138
+ # custom_meta_image_url = "https://chainlit-cloud.s3.eu-west-3.amazonaws.com/logo/chainlit_banner.png"
139
+
140
+ # Load assistant logo directly from URL.
141
+ logo_file_url = ""
142
+
143
+ # Load assistant avatar image directly from URL.
144
+ default_avatar_file_url = ""
145
+
146
+ # Specify a custom build directory for the frontend.
147
+ # This can be used to customize the frontend code.
148
+ # Be careful: If this is a relative path, it should not start with a slash.
149
+ # custom_build = "./public/build"
150
+
151
+ # Specify optional one or more custom links in the header.
152
+ # [[UI.header_links]]
153
+ # name = "Issues"
154
+ # display_name = "Report Issue"
155
+ # icon_url = "https://avatars.githubusercontent.com/u/128686189?s=200&v=4"
156
+ # url = "https://github.com/Chainlit/chainlit/issues"
157
+ # target = "_blank" (default) # Optional: "_self", "_parent", "_top".
158
+
159
+ [meta]
160
+ generated_by = "2.9.4"
.gitignore CHANGED
@@ -208,4 +208,5 @@ __marimo__/
208
 
209
  # Chainlit
210
 
211
- .chainlit/
 
 
208
 
209
  # Chainlit
210
 
211
+ # Ignore auto-generated translations but keep config
212
+ .chainlit/translations/
Dockerfile CHANGED
@@ -11,9 +11,10 @@ RUN pip install --no-cache-dir -r requirements.txt
11
  # Copy application files
12
  COPY app.py .
13
  COPY prompt.md .
 
14
 
15
- # Create chainlit config directory to avoid ContextVar issues
16
- RUN mkdir -p /app/.chainlit
17
 
18
  # Expose port 7860 (required for Hugging Face Spaces)
19
  EXPOSE 7860
 
11
  # Copy application files
12
  COPY app.py .
13
  COPY prompt.md .
14
+ COPY chainlit.md .
15
 
16
+ # Copy Chainlit configuration (with customizations)
17
+ COPY .chainlit/ .chainlit/
18
 
19
  # Expose port 7860 (required for Hugging Face Spaces)
20
  EXPOSE 7860
app.py CHANGED
@@ -74,8 +74,24 @@ async def on_chat_start():
74
  # Mark that this is a new session (for welcome message)
75
  cl.user_session.set("first_message", True)
76
 
77
- # Don't send messages here to avoid ContextVar issues in deployment
78
- # Messages will be handled in on_message instead
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
 
81
  def is_simple_greeting(text: str) -> bool:
@@ -95,8 +111,10 @@ async def on_message(message: cl.Message):
95
  chat_history = InMemoryChatMessageHistory()
96
  cl.user_session.set("chat_history", chat_history)
97
 
98
- # Check if this is the first message and send welcome message
99
  is_first = cl.user_session.get("first_message", False)
 
 
100
  if is_first:
101
  cl.user_session.set("first_message", False)
102
 
@@ -107,14 +125,16 @@ async def on_message(message: cl.Message):
107
  ).send()
108
  return
109
 
110
- # Send welcome message - according to prompt section 1.6, ask ONE question: "What are you working on?"
111
- welcome_msg = "What are you working on?"
112
- await cl.Message(content=welcome_msg).send()
 
113
 
114
- # Add welcome message to chat history and persist back to session
115
- from langchain_core.messages import AIMessage
116
- chat_history.add_message(AIMessage(content=welcome_msg))
117
- cl.user_session.set("chat_history", chat_history) # Persist changes
 
118
 
119
  # If the user's first message is just a greeting, don't process it
120
  # Otherwise, continue to process their meaningful response
 
74
  # Mark that this is a new session (for welcome message)
75
  cl.user_session.set("first_message", True)
76
 
77
+ # Try to send welcome message here (works locally and sometimes in deployment)
78
+ # If it fails due to ContextVar issues, we'll send it on first message instead
79
+ try:
80
+ if ANTHROPIC_API_KEY:
81
+ welcome_msg = "What are you working on?"
82
+ await cl.Message(content=welcome_msg).send()
83
+
84
+ # Add welcome message to chat history
85
+ from langchain_core.messages import AIMessage
86
+ chat_history.add_message(AIMessage(content=welcome_msg))
87
+ cl.user_session.set("chat_history", chat_history)
88
+
89
+ # Mark that welcome message was sent
90
+ cl.user_session.set("welcome_sent", True)
91
+ except (LookupError, RuntimeError, Exception) as e:
92
+ # ContextVar or other initialization error - will send welcome on first message instead
93
+ print(f"Could not send welcome message in on_chat_start: {e}")
94
+ cl.user_session.set("welcome_sent", False)
95
 
96
 
97
  def is_simple_greeting(text: str) -> bool:
 
111
  chat_history = InMemoryChatMessageHistory()
112
  cl.user_session.set("chat_history", chat_history)
113
 
114
+ # Check if this is the first message and send welcome message (if not already sent in on_chat_start)
115
  is_first = cl.user_session.get("first_message", False)
116
+ welcome_sent = cl.user_session.get("welcome_sent", False)
117
+
118
  if is_first:
119
  cl.user_session.set("first_message", False)
120
 
 
125
  ).send()
126
  return
127
 
128
+ # Send welcome message only if it wasn't sent in on_chat_start
129
+ if not welcome_sent:
130
+ welcome_msg = "What are you working on?"
131
+ await cl.Message(content=welcome_msg).send()
132
 
133
+ # Add welcome message to chat history and persist back to session
134
+ from langchain_core.messages import AIMessage
135
+ chat_history.add_message(AIMessage(content=welcome_msg))
136
+ # Persist changes
137
+ cl.user_session.set("chat_history", chat_history)
138
 
139
  # If the user's first message is just a greeting, don't process it
140
  # Otherwise, continue to process their meaningful response
chainlit.md CHANGED
@@ -1,14 +1,5 @@
1
- # Welcome to Chainlit! ๐Ÿš€๐Ÿค–
2
 
3
- Hi there, Developer! ๐Ÿ‘‹ We're excited to have you on board. Chainlit is a powerful tool designed to help you prototype, debug and share applications built on top of LLMs.
4
 
5
- ## Useful Links ๐Ÿ”—
6
-
7
- - **Documentation:** Get started with our comprehensive [Chainlit Documentation](https://docs.chainlit.io) ๐Ÿ“š
8
- - **Discord Community:** Join our friendly [Chainlit Discord](https://discord.gg/k73SQ3FyUh) to ask questions, share your projects, and connect with other developers! ๐Ÿ’ฌ
9
-
10
- We can't wait to see what you create with Chainlit! Happy coding! ๐Ÿ’ป๐Ÿ˜Š
11
-
12
- ## Welcome screen
13
-
14
- To modify the welcome screen, edit the `chainlit.md` file at the root of your project. If you do not want a welcome screen, just leave this file empty.
 
1
+ # Welcome! ๐Ÿ‘‹
2
 
3
+ I'm your Design Thinking Coach, here to guide you through the creative problem-solving process.
4
 
5
+ Let's start by understanding what you're working on.