ju-bezdek / langchain-decorators

syntactic sugar 🍭 for langchain
MIT License
228 stars 11 forks source link

RAG Chain Example #13

Open amitjoy opened 9 months ago

amitjoy commented 9 months ago

The project is very similar to the concept of AIServices in LangChain4J. I really love the idea.

Is it possible for you to provide an example of using RAG chain with the help of decorators?

ju-bezdek commented 9 months ago

The easiest RAG that you can do is just include the RAW search results into the prompt to provide the reply... but there are also more sophisticated RAG strategies... depends on your needs...

the easiest way is just include the search results into the prompt...

I've created a quick example that is showcasing a bit more complex situation where you want to provide also sources and limit the hallucinations... (for instance you could even include instruction to only answer if we have results, to make sure that LLM wont try to answer the question without evidence)

rag_example.py

amitjoy commented 9 months ago

@ju-bezdek Thank you very much for your prompt reply. I am keenly interested in integrating with the langchain version of RAG in order to leverage vector databases alongside retriever chains, as outlined in [1]. I would greatly appreciate it if you could kindly provide a pertinent example to facilitate the implementation described in [1].

[1] - https://python.langchain.com/docs/expression_language/cookbook/retrieval