Spaces:
Sleeping
Sleeping
gera
commited on
Commit
•
4baeaea
1
Parent(s):
b138a26
apametrized ASSISTANT and VECTOR ID
Browse files
app.py
CHANGED
@@ -5,8 +5,8 @@ import gradio as gr
|
|
5 |
from openai import OpenAI
|
6 |
client = OpenAI()
|
7 |
|
8 |
-
assistant_id = "
|
9 |
-
vector_id = "
|
10 |
|
11 |
ANS_SHORT = "Resumida"
|
12 |
ANS_REGULAR = "Normal"
|
@@ -118,37 +118,40 @@ AUTH_JS = """function auth_js(token, state) {
|
|
118 |
"""
|
119 |
|
120 |
|
121 |
-
with gr.Blocks(
|
122 |
-
|
123 |
-
|
124 |
-
gr.
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
[
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
|
|
|
|
|
|
152 |
|
153 |
demo.launch(
|
154 |
height=700,
|
|
|
5 |
from openai import OpenAI
|
6 |
client = OpenAI()
|
7 |
|
8 |
+
assistant_id = os_getenv("OPENAI_ASSISTANT_ID")
|
9 |
+
vector_id = os_getenv("OPENAI_VECTOR_ID")
|
10 |
|
11 |
ANS_SHORT = "Resumida"
|
12 |
ANS_REGULAR = "Normal"
|
|
|
118 |
"""
|
119 |
|
120 |
|
121 |
+
with gr.Blocks(
|
122 |
+
title="Dr. Luis Chiozza - Medicina y Psicoanalisis",
|
123 |
+
fill_height=True,
|
124 |
+
theme=gr.themes.Base()) as demo:
|
125 |
+
state = new_state()
|
126 |
+
|
127 |
+
gr.HTML("""
|
128 |
+
<h1>Dr. Luis Chiozza - Medicina y Psicoanalisis</h1>
|
129 |
+
<p>Habla con la colección de Medicina y Psicoanalisis del Dr. Luis Chiozza</p>
|
130 |
+
""")
|
131 |
+
with gr.Row(variant="compact"):
|
132 |
+
gr.HTML("Largo de la respuesta")
|
133 |
+
long_or_short = gr.Radio(
|
134 |
+
choices = [ANS_SHORT, ANS_REGULAR, ANS_LONG],
|
135 |
+
value = ANS_REGULAR,
|
136 |
+
show_label=False,
|
137 |
+
container=False,
|
138 |
+
label = "Largo de la respuesta",
|
139 |
+
scale=3)
|
140 |
+
|
141 |
+
gr.ChatInterface(
|
142 |
+
chat,
|
143 |
+
additional_inputs=[state, long_or_short],
|
144 |
+
examples=[
|
145 |
+
["Qué diferencias hay entre el cuerpo y el Alma?"],
|
146 |
+
["Cuáles son las distintas funciones de los órganos del cuerpo y su relación con el alma?"],
|
147 |
+
],
|
148 |
+
)
|
149 |
+
|
150 |
+
token = gr.Textbox(visible=False)
|
151 |
+
demo.load(auth,
|
152 |
+
[token,state],
|
153 |
+
[token,state],
|
154 |
+
js=AUTH_JS)
|
155 |
|
156 |
demo.launch(
|
157 |
height=700,
|