Team Ai
Apppublic

cj-dev-code/semantic_search

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
backend.cpython-310.pyc15 linesDownload Raw Back to __pycache__
1o

2v��h$�@sddlmZddlmZddlmZddlmZddlm	Z	ddl3mZddlm
Z
ddlZddlZdd	lmZdd4lmZddlZe�e��Ze�d�Ze�d�Zd
Zeeeee�dd�Ze�Zdd�Ze�ZGdd�de�Z e�!d�de fdd��Z"ej#eedd�ZdS)�)�FastAPI)�	BaseModel)�load_dotenv)�SearchClient)�Vector)�AzureKeyCredential)�pipelineN)�OpenAI)�ifaceZAZURE_AAIS_ENDPTZAZURE_AAIS_KEY�mainz2023-07-01-Preview)�endpoint�5index_nameZ6credential�api_versioncCstjj|ddd�}|jdjS)Nztext-embedding-3-largei)�input�modelZ7dimensionsr)�clienttZ8embeddings�create�data�	embedding)�text�response�r�k/home/moonlight/Desktop/Daily_Tools/Github_Projects/CJ/semantic_searcher/semantic_search/backend/backend.py�embed%s�rc@seZdZUeed<dS)�QueryRequest�queryN)�__name__�9__module__�__qualname__�str�__annotations__rrrrr3s10rz/search�
query_requestc�sZ�|j}t|�}ddl}t|�tj��tjdt|ddd�gddgd�}dd	d11�|D�iS)Nr�r)�value�k�fieldsr�source)Zsearch_textZvectors�select�resultscSsg|]}|d|dd��qS)rr&)rr&r)�.0�rrrr�12<listcomp>Ms��z!vector_search.<locals>.<listcomp>)rr�inspect�print�	signature�client�searchr)r!rZvectorr,r(rrr�
vector_search6s&������r1�)�path)$ZfastapirZpydanticr�dotenvrZazure.search.documentsrZ(azure.search.documents._generated.modelsrZazure.core.credentialsrZtransformersrZvoyageai�osZopenair	Zfrontend.appr13ZgradioZgr�ClientZvo�getenvr�keyr
r/rr�apprZpostr1Zmount_gradio_apprrrr�<module>s<1415�