123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- ---
- title: '📱 App types'
- ---
- ## App Types
- We have three types of App.
- ### App
- ```python
- from embedchain import App
- app = App()
- ```
- - `App` uses OpenAI's model, so these are paid models. 💸 You will be charged for embedding model usage and LLM usage.
- - `App` uses OpenAI's embedding model to create embeddings for chunks and ChatGPT API as LLM to get answer given the relevant docs. Make sure that you have an OpenAI account and an API key. If you have don't have an API key, you can create one by visiting [this link](https://platform.openai.com/account/api-keys).
- - `App` is opinionated. It uses the best embedding model and LLM on the market.
- - Once you have the API key, set it in an environment variable called `OPENAI_API_KEY`
- ```python
- import os
- os.environ["OPENAI_API_KEY"] = "sk-xxxx"
- ```
- ### Llama2App
- ```python
- import os
- from embedchain import Llama2App
- os.environ['REPLICATE_API_TOKEN'] = "REPLICATE API TOKEN"
- zuck_bot = Llama2App()
- # Embed your data
- zuck_bot.add("youtube_video", "https://www.youtube.com/watch?v=Ff4fRgnuFgQ")
- zuck_bot.add("web_page", "https://en.wikipedia.org/wiki/Mark_Zuckerberg")
- # Nice, your bot is ready now. Start asking questions to your bot.
- zuck_bot.query("Who is Mark Zuckerberg?")
- # Answer: Mark Zuckerberg is an American internet entrepreneur and business magnate. He is the co-founder and CEO of Facebook. Born in 1984, he dropped out of Harvard University to focus on his social media platform, which has since grown to become one of the largest and most influential technology companies in the world.
- # Enable web search for your bot
- zuck_bot.online = True # enable internet access for the bot
- zuck_bot.query("Who owns the new threads app and when it was founded?")
- # Answer: Based on the context provided, the new Threads app is owned by Meta, the parent company of Facebook, Instagram, and WhatsApp.
- ```
- - `Llama2App` uses Replicate's LLM model, so these are paid models. You can get the `REPLICATE_API_TOKEN` by registering on [their website](https://replicate.com/account).
- - `Llama2App` uses OpenAI's embedding model to create embeddings for chunks. Make sure that you have an OpenAI account and an API key. If you have don't have an API key, you can create one by visiting [this link](https://platform.openai.com/account/api-keys).
- ### OpenSourceApp
- ```python
- from embedchain import OpenSourceApp
- app = OpenSourceApp()
- ```
- - `OpenSourceApp` uses open source embedding and LLM model. It uses `all-MiniLM-L6-v2` from Sentence Transformers library as the embedding model and `gpt4all` as the LLM.
- - Here there is no need to setup any api keys. You just need to install embedchain package and these will get automatically installed. 📦
- - Once you have imported and instantiated the app, every functionality from here onwards is the same for either type of app. 📚
- - `OpenSourceApp` is opinionated. It uses the best open source embedding model and LLM on the market.
- ### CustomApp
- ```python
- from embedchain import CustomApp
- from embedchain.config import CustomAppConfig
- from embedchain.models import Providers, EmbeddingFunctions
- config = CustomAppConfig(embedding_fn=EmbeddingFunctions.OPENAI, provider=Providers.OPENAI)
- app = CustomApp(config)
- ```
- - `CustomApp` is not opinionated.
- - Configuration required. It's for advanced users who want to mix and match different embedding models and LLMs. Configuration required.
- - while it's doing that, it's still providing abstractions through `Providers`.
- - paid and free/open source providers included.
- - Once you have imported and instantiated the app, every functionality from here onwards is the same for either type of app. 📚
- - Following providers are available for an LLM
- - OPENAI
- - ANTHPROPIC
- - VERTEX_AI
- - GPT4ALL
- - AZURE_OPENAI
- - Following embedding functions are available for an embedding function
- - OPENAI
- - HUGGING_FACE
- - VERTEX_AI
- - GPT4ALL
- - AZURE_OPENAI
- ### PersonApp
- ```python
- from embedchain import PersonApp
- naval_chat_bot = PersonApp("name_of_person_or_character") #Like "Yoda"
- ```
- - `PersonApp` uses OpenAI's model, so these are paid models. 💸 You will be charged for embedding model usage and LLM usage.
- - `PersonApp` uses OpenAI's embedding model to create embeddings for chunks and ChatGPT API as LLM to get answer given the relevant docs. Make sure that you have an OpenAI account and an API key. If you have don't have an API key, you can create one by visiting [this link](https://platform.openai.com/account/api-keys).
- - Once you have the API key, set it in an environment variable called `OPENAI_API_KEY`
- ```python
- import os
- os.environ["OPENAI_API_KEY"] = "sk-xxxx"
- ```
- #### Compatibility with other apps
- - If there is any other app instance in your script or app, you can change the import as
- ```python
- from embedchain import App as EmbedChainApp
- from embedchain import OpenSourceApp as EmbedChainOSApp
- from embedchain import PersonApp as EmbedChainPersonApp
- # or
- from embedchain import App as ECApp
- from embedchain import OpenSourceApp as ECOSApp
- from embedchain import PersonApp as ECPApp
- ```
|