File size: 1,543 Bytes
c3f805b
982916b
 
 
 
 
 
 
63956c4
 
982916b
 
 
 
 
 
 
 
 
 
 
 
63956c4
982916b
 
 
 
 
 
c3f805b
982916b
 
 
c3f805b
 
982916b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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()