Merge branch 'main' into fix-wrong-apikey

Signed-off-by: Kaveen Kumarasinghe <k5kumara@uwaterloo.ca>
Kaveen Kumarasinghe 2 years ago committed by GitHub
commit a0c0be181e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -32,7 +32,7 @@ from services.environment_service import EnvService
from models.openai_model import Model
__version__ = "10.9.15"
__version__ = "10.9.16"
PID_FILE = Path("bot.pid")

@ -20,6 +20,7 @@ from discord.ext import pages
from langchain.llms import OpenAIChat
from llama_index.langchain_helpers.chatgpt import ChatGPTLLMPredictor
from langchain import OpenAI
from llama_index.optimization.optimizer import SentenceEmbeddingOptimizer
from llama_index.prompts.chat_prompts import CHAT_REFINE_PROMPT
from llama_index.readers import YoutubeTranscriptReader
@ -55,7 +56,7 @@ RemoteReader = download_loader("RemoteReader")
RemoteDepthReader = download_loader("RemoteDepthReader")
def get_and_query(
async def get_and_query(
user_id,
index_storage,
query,
@ -69,23 +70,23 @@ def get_and_query(
user_id
].get_index_or_throw()
if isinstance(index, GPTTreeIndex):
response = index.query(
response = await index.aquery(
query,
child_branch_factor=child_branch_factor,
llm_predictor=llm_predictor,
refine_template=CHAT_REFINE_PROMPT,
embed_model=embed_model,
use_async=True,
# optimizer=SentenceEmbeddingOptimizer(threshold_cutoff=0.7)
)
else:
response = index.query(
response = await index.aquery(
query,
response_mode=response_mode,
llm_predictor=llm_predictor,
embed_model=embed_model,
similarity_top_k=nodes,
refine_template=CHAT_REFINE_PROMPT,
use_async=True,
# optimizer=SentenceEmbeddingOptimizer(threshold_cutoff=0.7)
)
return response
@ -928,19 +929,15 @@ class Index_handler:
try:
embedding_model = OpenAIEmbedding()
embedding_model.last_token_usage = 0
response = await self.loop.run_in_executor(
None,
partial(
get_and_query,
ctx.user.id,
self.index_storage,
query,
response_mode,
nodes,
llm_predictor,
embedding_model,
child_branch_factor,
),
response = await get_and_query(
ctx.user.id,
self.index_storage,
query,
response_mode,
nodes,
llm_predictor,
embedding_model,
child_branch_factor,
)
print("The last token usage was ", llm_predictor.last_token_usage)
await self.usage_service.update_usage(

@ -455,35 +455,24 @@ class Search:
embedding_model.last_token_usage = 0
if not deep:
response = await self.loop.run_in_executor(
None,
partial(
index.query,
query,
embed_model=embedding_model,
llm_predictor=llm_predictor,
refine_template=CHAT_REFINE_PROMPT,
similarity_top_k=nodes or DEFAULT_SEARCH_NODES,
text_qa_template=self.qaprompt,
use_async=True,
response_mode=response_mode,
),
response = await index.aquery(
query,
embed_model=embedding_model,
llm_predictor=llm_predictor,
refine_template=CHAT_REFINE_PROMPT,
similarity_top_k=nodes or DEFAULT_SEARCH_NODES,
text_qa_template=self.qaprompt,
response_mode=response_mode,
)
else:
response = await self.loop.run_in_executor(
None,
partial(
index.query,
query,
embedding_mode="hybrid",
llm_predictor=llm_predictor,
refine_template=CHAT_REFINE_PROMPT,
include_text=True,
embed_model=embedding_model,
use_async=True,
similarity_top_k=nodes or DEFAULT_SEARCH_NODES,
response_mode=response_mode,
),
response = await index.aquery(
query,
embed_model=embedding_model,
llm_predictor=llm_predictor,
refine_template=CHAT_REFINE_PROMPT,
similarity_top_k=nodes or DEFAULT_SEARCH_NODES,
text_qa_template=self.qaprompt,
response_mode=response_mode,
)
await self.usage_service.update_usage(

@ -32,14 +32,15 @@ dependencies = [
"sqlitedict==2.1.0",
"backoff==2.2.1",
"flask==2.2.3",
"llama-index==0.4.23",
"llama-index==0.4.26",
"PyPDF2==3.0.1",
"youtube_transcript_api==0.5.0",
"sentencepiece==0.1.97",
"protobuf==3.20.2",
"python-pptx==0.6.21",
"langchain==0.0.105",
"unidecode==1.3.6"
"unidecode==1.3.6",
"tqdm==4.64.1"
]
dynamic = ["version"]
@ -58,7 +59,6 @@ full = [
"torch==1.9.1",
"torchvision==1.10.1",
"tokenizers==0.10.3",
"tqdm==4.64.1",
"numpy==1.24.2",
"scipy==1.10.1",
"nltk==3.8.1",

@ -12,7 +12,7 @@ pinecone-client==2.1.0
sqlitedict==2.1.0
backoff==2.2.1
flask==2.2.3
llama-index==0.4.23
llama-index==0.4.26
PyPDF2==3.0.1
youtube_transcript_api==0.5.0
sentencepiece==0.1.97
@ -22,3 +22,4 @@ sentence-transformers==2.2.2
langchain==0.0.105
openai-whisper
unidecode==1.3.6
tqdm==4.64.1

@ -12,11 +12,12 @@ pinecone-client==2.1.0
sqlitedict==2.1.0
backoff==2.2.1
flask==2.2.3
llama-index==0.4.23
llama-index==0.4.26
PyPDF2==3.0.1
youtube_transcript_api==0.5.0
sentencepiece==0.1.97
protobuf==3.20.2
python-pptx==0.6.21
langchain==0.0.105
unidecode==1.3.6
unidecode==1.3.6
tqdm==4.64.1

@ -1,5 +1,4 @@
tokenizers==0.13.2
tqdm==4.64.1
numpy==1.24.2
scipy==1.10.1
nltk==3.8.1

Loading…
Cancel
Save