Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,30 +1,20 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
-
|
| 5 |
-
client = InferenceClient(MODEL)
|
| 6 |
|
| 7 |
def chat(message, history):
|
| 8 |
-
|
| 9 |
for user, bot in history:
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
| 15 |
temperature=0.7,
|
| 16 |
-
top_p=0.9
|
| 17 |
-
repetition_penalty=1.1,
|
| 18 |
-
stream=False
|
| 19 |
)
|
| 20 |
-
return
|
| 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()
|