I attempted to use the callback function from langchain.callbacks to monitor the cost of each OpenAI request in my application, as demonstrated in the langchain-ask-pdf project video. However, I discovered that it wasn't providing any data. I suspect that the current version of langchain doesn't support the functionality for ChatOpenAI and OpenAIEmbeddings, or perhaps I made an error in my implementation.
I have included the code I used below. Any assistance with this issue would be greatly appreciated.
Code for OpenAIEmbeddings()
def create_vectorstore(text_chunks):
embeddings = OpenAIEmbeddings()
# embeddings = HuggingFaceInstructEmbeddings(model_name="hkunlp/instructor-xl")
with get_openai_callback() as cost:
vectorstore = FAISS.from_texts(texts=text_chunks, embedding=embeddings)
print(cost)
return vectorstore
I attempted to use the callback function from langchain.callbacks to monitor the cost of each OpenAI request in my application, as demonstrated in the langchain-ask-pdf project video. However, I discovered that it wasn't providing any data. I suspect that the current version of langchain doesn't support the functionality for
ChatOpenAI
andOpenAIEmbeddings
, or perhaps I made an error in my implementation.I have included the code I used below. Any assistance with this issue would be greatly appreciated.