Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -87,13 +87,16 @@ def process_query(query_text: str, vectorstore):
|
|
87 |
# Updated HuggingFaceEndpoint configuration
|
88 |
# Используем модель t5-base вместо google/flan-t5-base
|
89 |
model = HuggingFaceEndpoint(
|
90 |
-
repo_id="
|
91 |
task="question-answering",
|
92 |
temperature=0.5,
|
93 |
max_length=512,
|
94 |
-
|
95 |
)
|
96 |
-
|
|
|
|
|
|
|
97 |
|
98 |
sources = list(set([doc.metadata.get("source", "") for doc, _ in results]))
|
99 |
return response_text, sources
|
|
|
87 |
# Updated HuggingFaceEndpoint configuration
|
88 |
# Используем модель t5-base вместо google/flan-t5-base
|
89 |
model = HuggingFaceEndpoint(
|
90 |
+
repo_id="deepset/roberta-base-squad2", # Модель для question-answering
|
91 |
task="question-answering",
|
92 |
temperature=0.5,
|
93 |
max_length=512,
|
94 |
+
# huggingfacehub_api_token=os.getenv("HUGGINGFACEHUB_API_TOKEN")
|
95 |
)
|
96 |
+
|
97 |
+
# Передаем вопрос и контекст в виде словаря
|
98 |
+
response = model.invoke({"question": query_text, "context": context_text})
|
99 |
+
response_text = response.get("answer", "Нет ответа")
|
100 |
|
101 |
sources = list(set([doc.metadata.get("source", "") for doc, _ in results]))
|
102 |
return response_text, sources
|