app_types.mdx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. ---
  2. title: '📱 App types'
  3. ---
  4. ## App Types
  5. We have three types of App.
  6. ### App
  7. ```python
  8. from embedchain import App
  9. app = App()
  10. ```
  11. - `App` uses OpenAI's model, so these are paid models. 💸 You will be charged for embedding model usage and LLM usage.
  12. - `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).
  13. - `App` is opinionated. It uses the best embedding model and LLM on the market.
  14. - Once you have the API key, set it in an environment variable called `OPENAI_API_KEY`
  15. ```python
  16. import os
  17. os.environ["OPENAI_API_KEY"] = "sk-xxxx"
  18. ```
  19. ### OpenSourceApp
  20. ```python
  21. from embedchain import OpenSourceApp
  22. app = OpenSourceApp()
  23. ```
  24. - `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.
  25. - Here there is no need to setup any api keys. You just need to install embedchain package and these will get automatically installed. 📦
  26. - Once you have imported and instantiated the app, every functionality from here onwards is the same for either type of app. 📚
  27. - `OpenSourceApp` is opinionated. It uses the best open source embedding model and LLM on the market.
  28. ### CustomApp
  29. ```python
  30. from embedchain import CustomApp
  31. from embedchain.config import CustomAppConfig
  32. from embedchain.models import Providers, EmbeddingFunctions
  33. config = CustomAppConfig(embedding_fn=EmbeddingFunctions.OPENAI, provider=Providers.OPENAI)
  34. app = CustomApp(config)
  35. ```
  36. - `CustomApp` is not opinionated.
  37. - Configuration required. It's for advanced users who want to mix and match different embedding models and LLMs. Configuration required.
  38. - while it's doing that, it's still providing abstractions through `Providers`.
  39. - paid and free/open source providers included.
  40. - Once you have imported and instantiated the app, every functionality from here onwards is the same for either type of app. 📚
  41. - Following providers are available for an LLM
  42. - OPENAI
  43. - ANTHPROPIC
  44. - VERTEX_AI
  45. - GPT4ALL
  46. - Following embedding functions are available for an embedding function
  47. - OPENAI
  48. - HUGGING_FACE
  49. - VERTEX_AI
  50. - GPT4ALL
  51. ### PersonApp
  52. ```python
  53. from embedchain import PersonApp
  54. naval_chat_bot = PersonApp("name_of_person_or_character") #Like "Yoda"
  55. ```
  56. - `PersonApp` uses OpenAI's model, so these are paid models. 💸 You will be charged for embedding model usage and LLM usage.
  57. - `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).
  58. - Once you have the API key, set it in an environment variable called `OPENAI_API_KEY`
  59. ```python
  60. import os
  61. os.environ["OPENAI_API_KEY"] = "sk-xxxx"
  62. ```
  63. #### Compatibility with other apps
  64. - If there is any other app instance in your script or app, you can change the import as
  65. ```python
  66. from embedchain import App as EmbedChainApp
  67. from embedchain import OpenSourceApp as EmbedChainOSApp
  68. from embedchain import PersonApp as EmbedChainPersonApp
  69. # or
  70. from embedchain import App as ECApp
  71. from embedchain import OpenSourceApp as ECOSApp
  72. from embedchain import PersonApp as ECPApp
  73. ```