Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,10 +14,11 @@ logging.basicConfig(level=logging.INFO)
|
|
| 14 |
load_dotenv()
|
| 15 |
|
| 16 |
# Configuraci贸n de la API de Flowise
|
| 17 |
-
#API_URL = os.getenv("API_URL", "https://livanarzuaga-test.hf.space/api/v1/prediction/
|
|
|
|
| 18 |
|
| 19 |
API_URL = os.getenv("API_URL","https://marie0501-boulder-weather-flowise.hf.space/api/v1/prediction/dd2d1375-8019-4f52-bc23-1d0845b4a0c1")
|
| 20 |
-
|
| 21 |
|
| 22 |
session = requests.Session()
|
| 23 |
|
|
@@ -27,7 +28,7 @@ session.mount('https://', HTTPAdapter(max_retries=retries))
|
|
| 27 |
|
| 28 |
def query(payload, api_url=API_URL):
|
| 29 |
try:
|
| 30 |
-
response = session.post(api_url, json=payload)
|
| 31 |
response.raise_for_status()
|
| 32 |
return response.json()
|
| 33 |
except requests.exceptions.HTTPError as http_err:
|
|
@@ -55,7 +56,7 @@ def get_response(user_input, history, api_url=API_URL):
|
|
| 55 |
|
| 56 |
# Incluir el historial completo en el payload
|
| 57 |
payload = {"question": user_input, "history": history}
|
| 58 |
-
response = query(payload, api_url
|
| 59 |
return response.get('text', "Error: No API response.")
|
| 60 |
|
| 61 |
def export_conversation(past, generated, file_path="conversation.json"):
|
|
@@ -97,7 +98,7 @@ if st.sidebar.button("Exportar conversaci贸n"):
|
|
| 97 |
st.sidebar.error(f"Error al exportar la conversaci贸n: {result}")
|
| 98 |
|
| 99 |
# Contenedor para el historial del chat
|
| 100 |
-
chat_container = st.
|
| 101 |
|
| 102 |
# Contenedor para la entrada de texto del usuario
|
| 103 |
with st.form(key='my_form', clear_on_submit=True):
|
|
|
|
| 14 |
load_dotenv()
|
| 15 |
|
| 16 |
# Configuraci贸n de la API de Flowise
|
| 17 |
+
#API_URL = os.getenv("API_URL", "https://livanarzuaga-test.hf.space/api/v1/prediction/2dba91d7-15b7-4475-b0ec-34a11ffbeab5")
|
| 18 |
+
|
| 19 |
|
| 20 |
API_URL = os.getenv("API_URL","https://marie0501-boulder-weather-flowise.hf.space/api/v1/prediction/dd2d1375-8019-4f52-bc23-1d0845b4a0c1")
|
| 21 |
+
head = {"Authorization": "Bearer o6Xy3bIuPhDJV_z0PefeuvbHO2X3yo3Rt7NSiW-bY4o"}
|
| 22 |
|
| 23 |
session = requests.Session()
|
| 24 |
|
|
|
|
| 28 |
|
| 29 |
def query(payload, api_url=API_URL):
|
| 30 |
try:
|
| 31 |
+
response = session.post(api_url, json=payload, headers = head )
|
| 32 |
response.raise_for_status()
|
| 33 |
return response.json()
|
| 34 |
except requests.exceptions.HTTPError as http_err:
|
|
|
|
| 56 |
|
| 57 |
# Incluir el historial completo en el payload
|
| 58 |
payload = {"question": user_input, "history": history}
|
| 59 |
+
response = query(payload, api_url)
|
| 60 |
return response.get('text', "Error: No API response.")
|
| 61 |
|
| 62 |
def export_conversation(past, generated, file_path="conversation.json"):
|
|
|
|
| 98 |
st.sidebar.error(f"Error al exportar la conversaci贸n: {result}")
|
| 99 |
|
| 100 |
# Contenedor para el historial del chat
|
| 101 |
+
chat_container = st.empty()
|
| 102 |
|
| 103 |
# Contenedor para la entrada de texto del usuario
|
| 104 |
with st.form(key='my_form', clear_on_submit=True):
|