chatbot_ecowe / app.py
giseldo's picture
Update app.py
982916b verified
raw
history blame
1.79 kB
import gradio as gr
from groq import Groq
# Inicializa o cliente Groq - você precisará de uma API key
client = Groq()
def generate_response(message, history):
# Cria um prompt no estilo ELIZA
prompt = """You are an expert chatbot in ecology, designed to teach high school students in an engaging and accessible way. Your goal is to explain topics such as food chains, biomes, ecosystems, climate change, biodiversity, and sustainability with clarity, interactivity, and enthusiasm.
Adapt your responses to the students' knowledge level, using real-world examples, simple analogies, and interactive questions to reinforce learning. Encourage critical thinking and student engagement through challenges, fun facts, and practical experiment suggestions.
If a student has doubts, be patient and rephrase explanations in different ways. When helpful, provide illustrations or bullet-point summaries. Always promote environmental awareness and scientific curiosity in a positive and inspiring way!."""
# Faz a chamada para a API do Groq
chat_completion = client.chat.completions.create(
messages=[
{
"role": "system",
"content": prompt
},
{
"role": "user",
"content": message
}
],
model="mixtral-8x7b-32768", # ou outro modelo disponível no Groq
temperature=0.7,
max_tokens=150
)
# Retorna a resposta gerada
return chat_completion.choices[0].message.content
# Cria a interface Gradio
demo = gr.ChatInterface(
generate_response,
title="Ecowe",
description="Educational Ecology Chatbot."
)
# Inicia a interface
demo.launch()