Skip to content

Commit

Permalink
remove cache
Browse files Browse the repository at this point in the history
  • Loading branch information
truskovskiyk committed Jan 23, 2025
1 parent f677776 commit 6840e07
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
21 changes: 1 addition & 20 deletions no-ocr-api/np_ocr/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,26 +100,7 @@ def update_status(self, new_status: str):
search_client = SearchClient(qdrant_uri=settings.QDRANT_URI, port=settings.QDRANT_PORT, https=settings.QDRANT_HTTPS, top_k=settings.TOP_K, base_url=settings.COLPALI_BASE_URL, token=settings.COLPALI_TOKEN)
ingest_client = IngestClient(qdrant_uri=settings.QDRANT_URI, port=settings.QDRANT_PORT, https=settings.QDRANT_HTTPS, index_threshold=settings.INDEXING_THRESHOLD, vector_size=settings.VECTOR_SIZE, quantile=settings.QUANTILE, top_k=settings.TOP_K, base_url=settings.COLPALI_BASE_URL, token=settings.COLPALI_TOKEN)

cache = dc.Cache("vllm_cache")

def cache_decorator(func):
def wrapper(*args, **kwargs):
user_query = kwargs.get("user_query")
user_id = kwargs.get("user_id")
case_name = kwargs.get("case_name")
pdf_name = kwargs.get("pdf_name")
pdf_page = kwargs.get("pdf_page")

cache_key = f"{user_id}_{case_name}_{pdf_name}_{pdf_page}_{user_query}"
if cache_key in cache:
return cache[cache_key]

result = func(*args, **kwargs)
cache[cache_key] = result
return result
return wrapper

@cache_decorator

@app.post("/vllm_call")
def vllm_call(
user_query: str = Form(...), user_id: str = Form(...), case_name: str = Form(...), pdf_name: str = Form(...), pdf_page: int = Form(...)
Expand Down
1 change: 1 addition & 0 deletions no-ocr-api/np_ocr/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def call_vllm(image_data: PIL.Image.Image, user_query: str, base_url: str, api_k
}}
"""

print(prompt)
buffered = BytesIO()
max_size = (512, 512)
image_data.thumbnail(max_size)
Expand Down

0 comments on commit 6840e07

Please sign in to comment.