gr.ChatInterface with popular LLM libraries and API providers.
We will cover the following libraries and API providers:
- Llama Index
- LangChain
- OpenAI
- Hugging Face
transformers - SambaNova
- Hyperbolic
- Anthropic’s Claude
Llama Index
Let’s start by usingllama-index on top of openai to build a RAG chatbot on any text or PDF files that you can demo and share in less than 30 lines of code. You’ll need to have an OpenAI key for this example (keep reading for the free, open-source equivalent!):
LangChain
Here’s an example usinglangchain on top of openai to build a general-purpose chatbot. As before, you’ll need to have an OpenAI key for this example:
OpenAI
Of course, we could also use theopenai library directly. Here’s a similar example to the LangChain one, but this time with streaming as well:
Hugging Face transformers
Of course, in many cases you want to run a chatbot locally. Here’s the equivalent example using the SmolLM2-135M-Instruct model using the Hugging Facetransformers library: