Spaces:
Running
Running
import gradio as gr | |
from groq import Groq | |
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!.""" | |
chat_completion = client.chat.completions.create( | |
messages=[ | |
{ | |
"role": "system", | |
"content": prompt | |
}, | |
{ | |
"role": "user", | |
"content": message | |
} | |
], | |
model="mixtral-8x7b-32768", | |
temperature=0.7, | |
max_tokens=150 | |
) | |
return chat_completion.choices[0].message.content | |
demo = gr.ChatInterface( | |
generate_response, | |
title="Ecowe", | |
description="Educational Ecology Chatbot." | |
) | |
demo.launch() |