feat: Put some starter questions
Browse files- app.py +33 -0
- public/msg_icons/chatbot.png +0 -0
- public/msg_icons/tools.png +0 -0
- public/msg_icons/usb.png +0 -0
app.py
CHANGED
|
@@ -12,6 +12,33 @@ from dotenv import load_dotenv
|
|
| 12 |
|
| 13 |
_ : bool = load_dotenv()
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
async def process_image(image: cl.Image):
|
| 16 |
"""
|
| 17 |
Processes an image file, reads its data, and converts it to a base64 encoded string.
|
|
@@ -30,6 +57,9 @@ async def process_image(image: cl.Image):
|
|
| 30 |
print(f"Error reading image file: {e}")
|
| 31 |
return {"type": "text", "text": f"Error processing image {image.name}."}
|
| 32 |
|
|
|
|
|
|
|
|
|
|
| 33 |
@cl.on_chat_start
|
| 34 |
async def on_chat_start():
|
| 35 |
thread_id = f"thread-{uuid.uuid4()}"
|
|
@@ -66,6 +96,9 @@ async def on_chat_start():
|
|
| 66 |
# Store model in session
|
| 67 |
cl.user_session.set("model", model)
|
| 68 |
|
|
|
|
|
|
|
|
|
|
| 69 |
@cl.on_message
|
| 70 |
async def on_message(message: cl.Message):
|
| 71 |
thread_id = cl.user_session.get("thread_id") # Retrieve the user-specific thread ID
|
|
|
|
| 12 |
|
| 13 |
_ : bool = load_dotenv()
|
| 14 |
|
| 15 |
+
#################################
|
| 16 |
+
# Quick Starter Questions
|
| 17 |
+
#################################
|
| 18 |
+
@cl.set_starters
|
| 19 |
+
async def set_starters():
|
| 20 |
+
return [
|
| 21 |
+
cl.Starter(
|
| 22 |
+
label="LangGraph Chatbot Creation",
|
| 23 |
+
message="Create a chatbot in LangGraph. Give it web access using tavily tool.",
|
| 24 |
+
icon="/public/msg_icons/chatbot.png",
|
| 25 |
+
),
|
| 26 |
+
|
| 27 |
+
cl.Starter(
|
| 28 |
+
label="Explain MCP",
|
| 29 |
+
message="Explain Model Context Protocol (MCP) to a non-tech person.",
|
| 30 |
+
icon="/public/msg_icons/usb.png",
|
| 31 |
+
),
|
| 32 |
+
cl.Starter(
|
| 33 |
+
label="Composio Tools Integration",
|
| 34 |
+
message="How can I connect Composio tools to my agent built with LangGraph?",
|
| 35 |
+
icon="/public/msg_icons/tools.png",
|
| 36 |
+
),
|
| 37 |
+
|
| 38 |
+
]
|
| 39 |
+
#################################
|
| 40 |
+
# Encoding Images
|
| 41 |
+
#################################
|
| 42 |
async def process_image(image: cl.Image):
|
| 43 |
"""
|
| 44 |
Processes an image file, reads its data, and converts it to a base64 encoded string.
|
|
|
|
| 57 |
print(f"Error reading image file: {e}")
|
| 58 |
return {"type": "text", "text": f"Error processing image {image.name}."}
|
| 59 |
|
| 60 |
+
#################################
|
| 61 |
+
# Chat Settings
|
| 62 |
+
#################################
|
| 63 |
@cl.on_chat_start
|
| 64 |
async def on_chat_start():
|
| 65 |
thread_id = f"thread-{uuid.uuid4()}"
|
|
|
|
| 96 |
# Store model in session
|
| 97 |
cl.user_session.set("model", model)
|
| 98 |
|
| 99 |
+
#################################
|
| 100 |
+
# Processing Messages
|
| 101 |
+
#################################
|
| 102 |
@cl.on_message
|
| 103 |
async def on_message(message: cl.Message):
|
| 104 |
thread_id = cl.user_session.get("thread_id") # Retrieve the user-specific thread ID
|
public/msg_icons/chatbot.png
ADDED
|
|
public/msg_icons/tools.png
ADDED
|
|
public/msg_icons/usb.png
ADDED
|
|