Skip to content

Commit

Permalink
support for import some Q&A text
Browse files Browse the repository at this point in the history
support for import some Q&A text
  • Loading branch information
CN-P5 committed Jan 19, 2025
1 parent d7d6286 commit 651dd24
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions api/core/rag/index_processor/processor/qa_index_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,14 @@ def _format_qa_document(self, flask_app: Flask, tenant_id: str, document_node, a
with flask_app.app_context():
try:
# qa model document
response = LLMGenerator.generate_qa_document(tenant_id, document_node.page_content, document_language)
document_qa_list = self._format_split_text(response)
qa_split_list = self._format_split_text(document_node.page_content)
if len(qa_split_list) >= 1 and "question" in qa_split_list[0] and "answer" in qa_split_list[0]:
document_qa_list = qa_split_list
else:
response = LLMGenerator.generate_qa_document(
tenant_id, document_node.page_content, document_language
)
document_qa_list = self._format_split_text(response)
qa_documents = []
for result in document_qa_list:
qa_document = Document(page_content=result["question"], metadata=document_node.metadata.copy())
Expand Down

0 comments on commit 651dd24

Please sign in to comment.