SergeyO7 commited on
Commit
8aaea4e
·
verified ·
1 Parent(s): 21d2a33

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
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="t5-base", # Модель, поддерживающая text2text-generation
91
  task="question-answering",
92
  temperature=0.5,
93
  max_length=512,
94
- # huggingfacehub_api_token=os.getenv("HUGGINGFACEHUB_API_TOKEN")
95
  )
96
- response_text = model.invoke(prompt) # Use invoke instead of predict
 
 
 
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