Nextgengirls commited on
Commit
944f7da
·
verified ·
1 Parent(s): db911b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -21
app.py CHANGED
@@ -1,30 +1,20 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
4
- MODEL = "mistralai/Mistral-7B-Instruct-v0.2"
5
- client = InferenceClient(MODEL)
6
 
7
  def chat(message, history):
8
- prompt = ""
9
  for user, bot in history:
10
- prompt += f"Usuario: {user}\nAsistente: {bot}\n"
11
- prompt += f"Usuario: {message}\nAsistente:"
12
- response = client.text_generation(
13
- prompt,
14
- max_new_tokens=200,
 
15
  temperature=0.7,
16
- top_p=0.9,
17
- repetition_penalty=1.1,
18
- stream=False
19
  )
20
- return response.strip()
21
-
22
- demo = gr.ChatInterface(
23
- fn=chat,
24
- title="Asistente de Becas",
25
- description="Responde preguntas sobre becas, universidades y estudios internacionales."
26
- )
27
-
28
- if __name__ == "__main__":
29
- demo.launch()
30
 
 
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
 
4
+ client = InferenceClient("mistralai/Mistral-7B-Instruct-v0.2")
 
5
 
6
  def chat(message, history):
7
+ full_prompt = ""
8
  for user, bot in history:
9
+ full_prompt += f"Usuario: {user}\nAsistente: {bot}\n"
10
+ full_prompt += f"Usuario: {message}\nAsistente:"
11
+
12
+ result = client.text_generation(
13
+ full_prompt,
14
+ max_new_tokens=300,
15
  temperature=0.7,
16
+ top_p=0.9
 
 
17
  )
18
+ return result.strip()
 
 
 
 
 
 
 
 
 
19
 
20
+ gr.ChatInterface(fn=chat).launch()