app_types.mdx 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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()
  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. ### PersonApp
  42. ```python
  43. from embedchain import PersonApp
  44. naval_chat_bot = PersonApp("name_of_person_or_character") #Like "Yoda"
  45. ```
  46. - `PersonApp` uses OpenAI's model, so these are paid models. 💸 You will be charged for embedding model usage and LLM usage.
  47. - `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).
  48. - Once you have the API key, set it in an environment variable called `OPENAI_API_KEY`
  49. ```python
  50. import os
  51. os.environ["OPENAI_API_KEY"] = "sk-xxxx"
  52. ```
  53. #### Compatibility with other apps
  54. - If there is any other app instance in your script or app, you can change the import as
  55. ```python
  56. from embedchain import App as EmbedChainApp
  57. from embedchain import OpenSourceApp as EmbedChainOSApp
  58. from embedchain import PersonApp as EmbedChainPersonApp
  59. # or
  60. from embedchain import App as ECApp
  61. from embedchain import OpenSourceApp as ECOSApp
  62. from embedchain import PersonApp as ECPApp
  63. ```