hwchase17/notion-qa

Add tiktoken to requirements.txt

ryanbrackney opened this issue · 3 comments

On a fresh container with minimal prereqs, first call results in:

`Traceback (most recent call last):
File "/opt/conda/lib/python3.10/site-packages/langchain/llms/openai.py", line 233, in get_num_tokens
import tiktoken
ModuleNotFoundError: No module named 'tiktoken'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/jovyan/work/notion-qa/qa.py", line 20, in
result = chain({"question": args.question})
File "/opt/conda/lib/python3.10/site-packages/langchain/chains/base.py", line 146, in call
raise e
File "/opt/conda/lib/python3.10/site-packages/langchain/chains/base.py", line 142, in call
outputs = self._call(inputs)
File "/opt/conda/lib/python3.10/site-packages/langchain/chains/qa_with_sources/base.py", line 97, in _call
answer, _ = self.combine_document_chain.combine_docs(docs, **inputs)
File "/opt/conda/lib/python3.10/site-packages/langchain/chains/combine_documents/map_reduce.py", line 150, in combine_docs
num_tokens = length_func(result_docs, **kwargs)
File "/opt/conda/lib/python3.10/site-packages/langchain/chains/combine_documents/stuff.py", line 79, in prompt_length
return self.llm_chain.llm.get_num_tokens(prompt)
File "/opt/conda/lib/python3.10/site-packages/langchain/llms/openai.py", line 235, in get_num_tokens
raise ValueError(
ValueError: Could not import tiktoken python package. This is needed in order to calculate get_num_tokens. Please it install it with `pip install tiktoken``

Installing fixes. Probably should be part of the requirements.txt

same here, hopefully the author merge the fix soon #5

+1

Also would be cool to add a Dockerfile?

I found the same thing. 'pip install tiktoken' solved the problem.