Turbiling commited on
Commit
d07163a
·
verified ·
1 Parent(s): d860a6c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -21
app.py CHANGED
@@ -1,25 +1,26 @@
1
- # app.py
 
 
 
 
 
 
 
 
 
2
 
3
- import chainlit as cl
4
- import os
5
- from groq import Groq
6
 
7
- # Initialize Groq client using Hugging Face secret
8
- groq_client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
9
 
10
- @cl.on_chat_start
11
- async def start_chat():
12
- await cl.Message(content="👋 Hello! I am your Chainlit + Groq AI Assistant. Ask me anything!").send()
13
 
14
- @cl.on_message
15
- async def handle_message(message: cl.Message):
16
- # Call Groq API using LLaMA3 model
17
- response = groq_client.chat.completions.create(
18
- model="llama3-8b-8192",
19
- messages=[
20
- {"role": "system", "content": "You are a helpful assistant."},
21
- {"role": "user", "content": message.content}
22
- ]
23
- )
24
- reply = response.choices[0].message.content
25
- await cl.Message(content=reply).send()
 
1
+ ---
2
+ title: "Chainlit Groq Chatbot"
3
+ emoji: "🤖"
4
+ colorFrom: "blue"
5
+ colorTo: "green"
6
+ sdk: "chainlit"
7
+ sdk_version: "0.7.600" # Optional: You can omit or update this version
8
+ app_file: "app.py"
9
+ pinned: false
10
+ ---
11
 
12
+ # 🤖 Chainlit Chatbot with Groq API
 
 
13
 
14
+ This is a simple AI chatbot powered by Chainlit and the Groq API (LLaMA 3). Deployed on Hugging Face Spaces.
 
15
 
16
+ ## How to Use
 
 
17
 
18
+ Just open the Space and start chatting! 🎉
19
+
20
+ ## Setup Instructions (for contributors)
21
+
22
+ 1. Create a secret key named `GROQ_API_KEY` in the Hugging Face Space settings.
23
+ 2. Upload the following files:
24
+ - `app.py`
25
+ - `requirements.txt`
26
+ - `README.md`