Notion QA
[RetrievalQAWithSourcesChain](https://texonom.com/retrievalqawithsourceschain-bc5c869b53a04396a36ab0acbb5c80d4) 


Ref [notion-qa](https://github.com/hwchase17/notion-qa)
```typegit clone https://github.com/hwchase17/notion-qacd notion-qa```


`[qa.py](http://qa.py)` append below another imports
```typeimport pathlibtemp = pathlib.PosixPathpathlib.PosixPath = pathlib.WindowsPath```

```typeOPENAI_API_KEY=pip install -r requirements.txt# install pytorch and transformerpip install --force-reinstall charset-normalizer==3.1.0python qa.py $query```




### If you want to change DB
change code `[ingest.py](http://ingest.py)` 
```typefor p in ps:    with open(p, encoding='UTF8') as f:```
`[main.py](http://main.py)` 
[model's maximum context length](https://github.com/hwchase17/langchain/issues/1349)
[map_reduce summarizer errors when using LLM with smaller context window](https://github.com/hwchase17/langchain/issues/434)
```typechain = VectorDBQAWithSourcesChain.from_llm(llm=OpenAI(temperature=0), vectorstore=store, reduce_k_below_max_tokens=True)```
and then replace Notion_DB folder
```typerm faiss_store.pklpython ingest.py```





