Meet your cheerful chat buddy! This app is your optimistic friend who always sees the bright side. From everyday questions to life’s big moments, get uplifting responses and positive vibes that’ll make you smile, no matter what you’re asking about!

Update app.py
All checks were successful
society-ai-hub-container-cache Actions Demo / build (push) Successful in 26s

This commit is contained in:
LiorDav 2024-11-06 17:40:47 +00:00
parent 892372de46
commit 35aa5db947

11
app.py

@ -7,6 +7,12 @@ client = OpenAI(
base_url='https://llama-3-2-3b.societyai.com/openai/v1',
)
# Define the system prompt to set the context or behavior of the LLM
SYSTEM_PROMPT = {
"role": "system",
"content": "You are CheerMate, the optimistic friend! Your goal is to bring positivity and encouragement in every response, no matter the question or situation. Always focus on the bright side, highlight opportunities, and give hopeful perspectives. If there's a challenge, emphasize resilience and personal growth. Keep your tone friendly, cheerful, and uplifting—you're here to make people smile and feel motivated!"
}
with gr.Blocks(css="footer {visibility: hidden}") as demo:
chatbot = gr.Chatbot(type="messages")
msg = gr.Textbox()
@ -14,12 +20,15 @@ with gr.Blocks(css="footer {visibility: hidden}") as demo:
def user(user_message, history: list):
"""Appends the user message to the conversation history."""
# If the system prompt is not in the history, add it
if not history:
history = [SYSTEM_PROMPT]
return "", history + [{"role": "user", "content": user_message}]
def bot(history: list):
"""Sends the conversation history to the vLLM API and streams the assistant's response."""
# Append an empty assistant message to history to fill in as we receive the response
history.append({"role": "assistant", "content": "You are CheerMate, the optimistic friend! Your goal is to bring positivity and encouragement in every response, no matter the question or situation. Always focus on the bright side, highlight opportunities, and give hopeful perspectives. If there's a challenge, emphasize resilience and personal growth. Keep your tone friendly, cheerful, and uplifting—you're here to make people smile and feel motivated!"})
history.append({"role": "assistant", "content": ""})
try:
# Create a chat completion with streaming enabled using the client