a Rails + Langchain Chatroom example using pycall.rb
- langchain: https://github.com/hwchase17/langchain
- pycall.rb: https://github.com/mrkn/pycall.rb
- my talk slide: https://ihower.tw/blog/archives/11596
- Langchain ChatOpenAI
- Langchain RetrievalQAChain (using OpenAIEmbedding + FAISS vector store) for PDF upload
- Langchain Agents (using python_repl)
- Ruby OpenAI gem
Using sucker_punch gem for demo purpose. If possible, I would recommend using delayed_job gem: https://github.com/collectiveidea/delayed_job
- There're some pycall.rb example at /examples
- Rails will load lib/lang_chain.rb
- Install Python 3:
brew install python
(Note: Open a new Terminal and make sure that which python3 has the newly installed python)
- Install Python packages:
pip3 install openai
pip3 install langchain
pip3 install tiktoken
pip3 install pypdf
pip3 install faiss-cpu
- Edit config/secrets.yml, Add your OpenAI API key
bundle
rake db:migrate
rails s