giseldo commited on
Commit
63956c4
·
verified ·
1 Parent(s): e19dc70

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -10
app.py CHANGED
@@ -1,16 +1,14 @@
1
  import gradio as gr
2
  from groq import Groq
3
 
4
- # Inicializa o cliente Groq - você precisará de uma API key
5
  client = Groq()
6
 
7
  def generate_response(message, history):
8
  # Cria um prompt no estilo ELIZA
9
  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.
10
- 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.
11
- 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!."""
12
 
13
- # Faz a chamada para a API do Groq
14
  chat_completion = client.chat.completions.create(
15
  messages=[
16
  {
@@ -22,22 +20,17 @@ def generate_response(message, history):
22
  "content": message
23
  }
24
  ],
25
- model="mixtral-8x7b-32768", # ou outro modelo disponível no Groq
26
  temperature=0.7,
27
  max_tokens=150
28
  )
29
 
30
- # Retorna a resposta gerada
31
  return chat_completion.choices[0].message.content
32
 
33
- # Cria a interface Gradio
34
-
35
-
36
  demo = gr.ChatInterface(
37
  generate_response,
38
  title="Ecowe",
39
  description="Educational Ecology Chatbot."
40
  )
41
 
42
- # Inicia a interface
43
  demo.launch()
 
1
  import gradio as gr
2
  from groq import Groq
3
 
 
4
  client = Groq()
5
 
6
  def generate_response(message, history):
7
  # Cria um prompt no estilo ELIZA
8
  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.
9
+ 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.
10
+ 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!."""
11
 
 
12
  chat_completion = client.chat.completions.create(
13
  messages=[
14
  {
 
20
  "content": message
21
  }
22
  ],
23
+ model="mixtral-8x7b-32768",
24
  temperature=0.7,
25
  max_tokens=150
26
  )
27
 
 
28
  return chat_completion.choices[0].message.content
29
 
 
 
 
30
  demo = gr.ChatInterface(
31
  generate_response,
32
  title="Ecowe",
33
  description="Educational Ecology Chatbot."
34
  )
35
 
 
36
  demo.launch()