Spaces:
Runtime error
Runtime error
Se cambio a sharegpt
Browse files
app.py
CHANGED
@@ -14,16 +14,29 @@ def respond(
|
|
14 |
max_tokens,
|
15 |
temperature,
|
16 |
top_p,
|
|
|
17 |
):
|
18 |
-
|
|
|
|
|
19 |
|
20 |
-
for
|
21 |
-
if
|
22 |
-
|
23 |
-
if
|
24 |
-
|
25 |
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
response = ""
|
29 |
|
@@ -33,6 +46,7 @@ def respond(
|
|
33 |
stream=True,
|
34 |
temperature=temperature,
|
35 |
top_p=top_p,
|
|
|
36 |
):
|
37 |
token = message.choices[0].delta.content
|
38 |
|
@@ -45,9 +59,9 @@ For information on how to customize the ChatInterface, peruse the gradio docs: h
|
|
45 |
demo = gr.ChatInterface(
|
46 |
respond,
|
47 |
additional_inputs=[
|
48 |
-
gr.Textbox(value="You are a
|
49 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
50 |
-
gr.Slider(minimum=0.1, maximum=4.0, value=
|
51 |
gr.Slider(
|
52 |
minimum=0.1,
|
53 |
maximum=1.0,
|
@@ -55,6 +69,13 @@ demo = gr.ChatInterface(
|
|
55 |
step=0.05,
|
56 |
label="Top-p (nucleus sampling)",
|
57 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
],
|
59 |
)
|
60 |
|
|
|
14 |
max_tokens,
|
15 |
temperature,
|
16 |
top_p,
|
17 |
+
min_p,
|
18 |
):
|
19 |
+
conversations = [
|
20 |
+
{"from": "system", "value": system_message}
|
21 |
+
]
|
22 |
|
23 |
+
for human, assistant in history:
|
24 |
+
if human:
|
25 |
+
conversations.append({"from": "human", "value": human})
|
26 |
+
if assistant:
|
27 |
+
conversations.append({"from": "gpt", "value": assistant})
|
28 |
|
29 |
+
conversations.append({"from": "human", "value": message})
|
30 |
+
|
31 |
+
# Convertir el formato de conversaciones al formato esperado por la API
|
32 |
+
messages = []
|
33 |
+
for conv in conversations:
|
34 |
+
if conv["from"] == "system":
|
35 |
+
messages.append({"role": "system", "content": conv["value"]})
|
36 |
+
elif conv["from"] == "human":
|
37 |
+
messages.append({"role": "user", "content": conv["value"]})
|
38 |
+
elif conv["from"] == "gpt":
|
39 |
+
messages.append({"role": "assistant", "content": conv["value"]})
|
40 |
|
41 |
response = ""
|
42 |
|
|
|
46 |
stream=True,
|
47 |
temperature=temperature,
|
48 |
top_p=top_p,
|
49 |
+
min_p=min_p
|
50 |
):
|
51 |
token = message.choices[0].delta.content
|
52 |
|
|
|
59 |
demo = gr.ChatInterface(
|
60 |
respond,
|
61 |
additional_inputs=[
|
62 |
+
gr.Textbox(value="You are SipanGPT, an artificial intelligence assistant responsible for providing technical support for the Information Technology Department (DTI) to students, professors, and administrative staff at the Señor de Sipán University, a private university in the Lambayeque region of Peru.", label="System message"),
|
63 |
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
64 |
+
gr.Slider(minimum=0.1, maximum=4.0, value=1.5, step=0.1, label="Temperature"),
|
65 |
gr.Slider(
|
66 |
minimum=0.1,
|
67 |
maximum=1.0,
|
|
|
69 |
step=0.05,
|
70 |
label="Top-p (nucleus sampling)",
|
71 |
),
|
72 |
+
gr.Slider(
|
73 |
+
minimum=0.1,
|
74 |
+
maximum=1.0,
|
75 |
+
value=0.1,
|
76 |
+
step=0.05,
|
77 |
+
label="min-p",
|
78 |
+
),
|
79 |
],
|
80 |
)
|
81 |
|