mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-05-24 18:50:06 +02:00
* bump fastapi and starlette * bumping llama index and nltk and associated deps * bump to fix python-multipart * bump aiohttp * update package lock for examples/widget * bump black * sentencesplitter has changed namespaces * fix reorder import check, fix missing passlib * update package-lock.json * black formatter updated * reformatted again * change to black compatible reorder * change to black compatible reorder-python-imports fork * fix pytest dependency * black format again * we don't need cdk.txt. update packages to be consistent across all packages --------- Co-authored-by: Richard Kuo (Onyx) <rkuo@onyx.app> Co-authored-by: Richard Kuo <rkuo@rkuo.com>
42 lines
1.6 KiB
Python
42 lines
1.6 KiB
Python
import requests
|
|
|
|
from ee.onyx.server.query_and_chat.models import DocumentSearchRequest
|
|
from onyx.context.search.enums import LLMEvaluationType
|
|
from onyx.context.search.enums import SearchType
|
|
from onyx.context.search.models import RetrievalDetails
|
|
from onyx.context.search.models import SavedSearchDocWithContent
|
|
from tests.integration.common_utils.constants import API_SERVER_URL
|
|
from tests.integration.common_utils.constants import GENERAL_HEADERS
|
|
from tests.integration.common_utils.test_models import DATestUser
|
|
|
|
|
|
class DocumentSearchManager:
|
|
@staticmethod
|
|
def search_documents(
|
|
query: str,
|
|
search_type: SearchType = SearchType.KEYWORD,
|
|
user_performing_action: DATestUser | None = None,
|
|
) -> list[str]:
|
|
search_request = DocumentSearchRequest(
|
|
message=query,
|
|
search_type=search_type,
|
|
retrieval_options=RetrievalDetails(),
|
|
evaluation_type=LLMEvaluationType.SKIP,
|
|
)
|
|
result = requests.post(
|
|
url=f"{API_SERVER_URL}/query/document-search",
|
|
json=search_request.model_dump(),
|
|
headers=(
|
|
user_performing_action.headers
|
|
if user_performing_action
|
|
else GENERAL_HEADERS
|
|
),
|
|
)
|
|
result.raise_for_status()
|
|
result_json = result.json()
|
|
top_documents: list[SavedSearchDocWithContent] = [
|
|
SavedSearchDocWithContent(**doc) for doc in result_json["top_documents"]
|
|
]
|
|
document_content_list: list[str] = [doc.content for doc in top_documents]
|
|
return document_content_list
|