create.mdx 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. ---
  2. openapi: post /create
  3. ---
  4. <RequestExample>
  5. ```bash Request
  6. curl --request POST \
  7. --url http://localhost:8080/create?app_id=app1 \
  8. -F "config=@/path/to/config.yaml"
  9. ```
  10. </RequestExample>
  11. <ResponseExample>
  12. ```json Response
  13. { "response": "App created successfully. App ID: app1" }
  14. ```
  15. </ResponseExample>
  16. By default we will use the opensource **gpt4all** model to get started. You can also specify your own config by uploading a config YAML file.
  17. For example, create a `config.yaml` file (adjust according to your requirements):
  18. ```yaml
  19. app:
  20. config:
  21. id: "default-app"
  22. llm:
  23. provider: openai
  24. config:
  25. model: "gpt-3.5-turbo"
  26. temperature: 0.5
  27. max_tokens: 1000
  28. top_p: 1
  29. stream: false
  30. template: |
  31. Use the following pieces of context to answer the query at the end.
  32. If you don't know the answer, just say that you don't know, don't try to make up an answer.
  33. $context
  34. Query: $query
  35. Helpful Answer:
  36. vectordb:
  37. provider: chroma
  38. config:
  39. collection_name: "rest-api-app"
  40. dir: db
  41. allow_reset: true
  42. embedder:
  43. provider: openai
  44. config:
  45. model: "text-embedding-ada-002"
  46. ```
  47. To learn more about custom configurations, check out the [custom configurations docs](https://docs.embedchain.ai/advanced/configuration). To explore more examples of config yamls for embedchain, visit [embedchain/configs](https://github.com/embedchain/embedchain/tree/main/configs).
  48. Now, you can upload this config file in the request body.
  49. For example,
  50. ```bash Request
  51. curl --request POST \
  52. --url http://localhost:8080/create?app_id=my-app \
  53. -F "config=@/path/to/config.yaml"
  54. ```
  55. **Note:** To use custom models, an **API key** might be required. Refer to the table below to determine the necessary API key for your provider.
  56. | Keys | Providers |
  57. | -------------------------- | ------------------------------ |
  58. | `OPENAI_API_KEY ` | OpenAI, Azure OpenAI, Jina etc |
  59. | `OPENAI_API_TYPE` | Azure OpenAI |
  60. | `OPENAI_API_BASE` | Azure OpenAI |
  61. | `OPENAI_API_VERSION` | Azure OpenAI |
  62. | `COHERE_API_KEY` | Cohere |
  63. | `TOGETHER_API_KEY` | Together |
  64. | `ANTHROPIC_API_KEY` | Anthropic |
  65. | `JINACHAT_API_KEY` | Jina |
  66. | `HUGGINGFACE_ACCESS_TOKEN` | Huggingface |
  67. | `REPLICATE_API_TOKEN` | LLAMA2 |
  68. To add env variables, you can simply run the docker command with the `-e` flag.
  69. For example,
  70. ```bash
  71. docker run --name embedchain -p 8080:8080 -e OPENAI_API_KEY=<YOUR_OPENAI_API_KEY> embedchain/rest-api:latest
  72. ```