Upload app.py with huggingface_hub
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from langchain_community.chat_models import ChatOllama
|
| 4 |
+
from langchain_core.output_parsers import StrOutputParser
|
| 5 |
+
from rerankers import Reranker
|
| 6 |
+
from langchain import hub
|
| 7 |
+
from langchain_community.vectorstores import Chroma
|
| 8 |
+
from langchain_huggingface import HuggingFaceEmbeddings
|
| 9 |
+
|
| 10 |
+
# Cargar todo lo necesario aquí (vectordb, ranker, etc.)
|
| 11 |
+
# Para ejemplo simple, simulamos función:
|
| 12 |
+
|
| 13 |
+
def test_rag_reranking(query, ranker=None):
|
| 14 |
+
return "Esta es una respuesta simulada a: " + query, None
|
| 15 |
+
|
| 16 |
+
def gradio_chatbot_fn(message, history):
|
| 17 |
+
respuesta, _ = test_rag_reranking(message)
|
| 18 |
+
return respuesta
|
| 19 |
+
|
| 20 |
+
iface = gr.ChatInterface(fn=gradio_chatbot_fn, title="Constitución Española - Chat RAG")
|
| 21 |
+
iface.launch()
|
| 22 |
+
|