add back token safeguard for search

Kaveen Kumarasinghe 2 years ago
parent 89a294d8b2
commit d1ea9868ad

@ -375,36 +375,35 @@ class Search:
llm_predictor_mock = MockLLMPredictor(4096) llm_predictor_mock = MockLLMPredictor(4096)
embed_model_mock = MockEmbedding(embed_dim=1536) embed_model_mock = MockEmbedding(embed_dim=1536)
# if ctx: if ctx:
# await self.try_edit( await self.try_edit(
# in_progress_message, self.build_search_determining_price_embed(query_refined_text) in_progress_message, self.build_search_determining_price_embed(query_refined_text)
# ) )
#
# await self.loop.run_in_executor( await self.loop.run_in_executor(
# None, None,
# partial( partial(
# GPTKnowledgeGraphIndex, GPTKnowledgeGraphIndex,
# documents, documents,
# chunk_size_limit=512, chunk_size_limit=512,
# max_triplets_per_chunk=2, max_triplets_per_chunk=2,
# embed_model=embed_model_mock, embed_model=embed_model_mock,
# llm_predictor=llm_predictor_mock, llm_predictor=llm_predictor_mock,
# ), ),
# ) )
# total_usage_price = await self.usage_service.get_price( total_usage_price = await self.usage_service.get_price(
# llm_predictor_mock.last_token_usage, chatgpt=True, llm_predictor_mock.last_token_usage, chatgpt=True,
# ) + await self.usage_service.get_price( ) + await self.usage_service.get_price(
# embed_model_mock.last_token_usage, embeddings=True embed_model_mock.last_token_usage, embeddings=True
# ) )
# print(f"Total usage price: {total_usage_price}") print(f"Total usage price: {total_usage_price}")
# if total_usage_price > MAX_SEARCH_PRICE: if total_usage_price > MAX_SEARCH_PRICE:
# await self.try_delete(in_progress_message) await self.try_delete(in_progress_message)
# raise ValueError( raise ValueError(
# "Doing this deep search would be prohibitively expensive. Please try a narrower search scope. This deep search indexing would have cost ${:.2f}.".format( "Doing this deep search would be prohibitively expensive. Please try a narrower search scope. This deep search indexing would have cost ${:.2f}.".format(
# total_usage_price total_usage_price
# ) )
# ) )
# # TODO Add back the mock when fixed!
index = await self.loop.run_in_executor( index = await self.loop.run_in_executor(
None, None,

@ -32,7 +32,7 @@ dependencies = [
"sqlitedict==2.1.0", "sqlitedict==2.1.0",
"backoff==2.2.1", "backoff==2.2.1",
"flask==2.2.3", "flask==2.2.3",
"llama-index==0.4.18", "llama-index==0.4.20",
"PyPDF2==3.0.1", "PyPDF2==3.0.1",
"youtube_transcript_api==0.5.0", "youtube_transcript_api==0.5.0",
"sentencepiece==0.1.97", "sentencepiece==0.1.97",

@ -12,7 +12,7 @@ pinecone-client==2.1.0
sqlitedict==2.1.0 sqlitedict==2.1.0
backoff==2.2.1 backoff==2.2.1
flask==2.2.3 flask==2.2.3
llama-index==0.4.18 llama-index==0.4.20
PyPDF2==3.0.1 PyPDF2==3.0.1
youtube_transcript_api==0.5.0 youtube_transcript_api==0.5.0
sentencepiece==0.1.97 sentencepiece==0.1.97

@ -12,7 +12,7 @@ pinecone-client==2.1.0
sqlitedict==2.1.0 sqlitedict==2.1.0
backoff==2.2.1 backoff==2.2.1
flask==2.2.3 flask==2.2.3
llama-index==0.4.18 llama-index==0.4.20
PyPDF2==3.0.1 PyPDF2==3.0.1
youtube_transcript_api==0.5.0 youtube_transcript_api==0.5.0
sentencepiece==0.1.97 sentencepiece==0.1.97

Loading…
Cancel
Save