Spaces:
				
			
			
	
			
			
		Runtime error
		
	
	
	
			
			
	
	
	
	
		
		
		Runtime error
		
	| import nh3 | |
| from fastapi import FastAPI, Request | |
| # from doc_searcher import DocSearcher | |
| from doc_searcher_v2 import DocSearcherV2 | |
| from huggingface_hub import login | |
| from config import HUGGING_FACE_API_KEY, COLLECTION_NAME, API_KEY, COLLECTION_NAME_SUGGESTION | |
| from fastapi.responses import StreamingResponse | |
| import httpx | |
| login(HUGGING_FACE_API_KEY) | |
| app = FastAPI() | |
| # doc_searcher = DocSearcher(collection_name=COLLECTION_NAME) | |
| doc_searcher_v2 = DocSearcherV2(collection_name=COLLECTION_NAME) | |
| ALLOWED_API_KEY = str(API_KEY) | |
| # @app.get("/api/search") | |
| # async def search(q: str, type: int, lt: str | None = None, offset: int = 0): | |
| # query = q.lower() | |
| # xss = nh3.clean(query) | |
| # data = await doc_searcher.search(text=xss,type=type,law_type=lt,offset=offset) | |
| # return data | |
| async def v2_search(q: str): | |
| query = q.lower() | |
| xss = nh3.clean(query) | |
| data = await doc_searcher_v2.search_semantic(text=xss) | |
| return data |