[REST API] Incorporate changes related to REST API docs (#900)
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
---
|
||||
openapi: post /{app_id}/add
|
||||
---
|
||||
@@ -1,3 +0,0 @@
|
||||
---
|
||||
openapi: post /{app_id}/deploy
|
||||
---
|
||||
@@ -7,10 +7,10 @@ title: "🌍 Getting Started"
|
||||
To run Embedchain as a REST API server use,
|
||||
|
||||
```bash
|
||||
docker run -d --name embedchain -p 8000:8000 embedchain/app:rest-api-latest
|
||||
docker run -d --name embedchain -p 8080:8080 embedchain/app:rest-api-latest
|
||||
```
|
||||
|
||||
Open up your browser and navigate to http://0.0.0.0:8000/docs to interact with the API. There is a full-fledged Swagger docs playground with all the information
|
||||
Open up your browser and navigate to http://0.0.0.0:8080/docs to interact with the API. There is a full-fledged Swagger docs playground with all the information
|
||||
about the API endpoints.
|
||||
|
||||

|
||||
@@ -83,7 +83,7 @@ To provide them, you can simply run the docker command with the `-e` flag.
|
||||
For example,
|
||||
|
||||
```bash
|
||||
docker run -d --name embedchain -p 8000:8000 -e OPENAI_API_KEY=YOUR_API_KEY embedchain/app:rest-api-latest
|
||||
docker run -d --name embedchain -p 8080:8080 -e OPENAI_API_KEY=YOUR_API_KEY embedchain/app:rest-api-latest
|
||||
```
|
||||
|
||||
Cool! This will create a new Embedchain App with the given `app_id`.
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
"pages": ["advanced/configuration"]
|
||||
},
|
||||
{
|
||||
"group": "Rest API",
|
||||
"group": "REST API",
|
||||
"pages": [
|
||||
"api-reference/getting-started",
|
||||
"api-reference/check-status",
|
||||
@@ -161,5 +161,8 @@
|
||||
},
|
||||
"search": {
|
||||
"prompt": "✨ Search embedchain docs..."
|
||||
},
|
||||
"api": {
|
||||
"baseUrl": "http://localhost:8080"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
"/ping": {
|
||||
"get": {
|
||||
"tags": ["Utility"],
|
||||
"summary": "Check Status",
|
||||
"description": "Endpoint to check the status of the API.",
|
||||
"summary": "Check status",
|
||||
"description": "Endpoint to check the status of the API",
|
||||
"operationId": "check_status_ping_get",
|
||||
"responses": {
|
||||
"200": {
|
||||
@@ -27,8 +27,8 @@
|
||||
"/apps": {
|
||||
"get": {
|
||||
"tags": ["Apps"],
|
||||
"summary": "Get All Apps",
|
||||
"description": "Get all apps.",
|
||||
"summary": "Get all apps",
|
||||
"description": "Get all applications",
|
||||
"operationId": "get_all_apps_apps_get",
|
||||
"responses": {
|
||||
"200": {
|
||||
@@ -41,8 +41,8 @@
|
||||
"/create": {
|
||||
"post": {
|
||||
"tags": ["Apps"],
|
||||
"summary": "Create App",
|
||||
"description": "Create a new app using App ID.",
|
||||
"summary": "Create app",
|
||||
"description": "Create a new app using App ID",
|
||||
"operationId": "create_app_using_default_config_create_post",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -89,8 +89,8 @@
|
||||
"/{app_id}/data": {
|
||||
"get": {
|
||||
"tags": ["Apps"],
|
||||
"summary": "Get Datasources Associated With App Id",
|
||||
"description": "Get all datasources for an app.",
|
||||
"summary": "Get data",
|
||||
"description": "Get all data sources for an app",
|
||||
"operationId": "get_datasources_associated_with_app_id__app_id__data_get",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -119,8 +119,8 @@
|
||||
"/{app_id}/add": {
|
||||
"post": {
|
||||
"tags": ["Apps"],
|
||||
"summary": "Add Datasource To An App",
|
||||
"description": "Add a source to an existing app.",
|
||||
"summary": "Add data",
|
||||
"description": "Add a data source to an app.",
|
||||
"operationId": "add_datasource_to_an_app__app_id__add_post",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -161,8 +161,8 @@
|
||||
"/{app_id}/query": {
|
||||
"post": {
|
||||
"tags": ["Apps"],
|
||||
"summary": "Query An App",
|
||||
"description": "Query an existing app.",
|
||||
"summary": "Query app",
|
||||
"description": "Query an app",
|
||||
"operationId": "query_an_app__app_id__query_post",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -203,8 +203,8 @@
|
||||
"/{app_id}/chat": {
|
||||
"post": {
|
||||
"tags": ["Apps"],
|
||||
"summary": "Chat With An App",
|
||||
"description": "Query an existing app.\n\napp_id: The ID of the app. Use \"default\" for the default app.\n\nmessage: The message that you want to send to the App.",
|
||||
"summary": "Chat",
|
||||
"description": "Chat with an app.\n\napp_id: The ID of the app. Use \"default\" for the default app.\n\nmessage: The message that you want to send to the app.",
|
||||
"operationId": "chat_with_an_app__app_id__chat_post",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -287,8 +287,8 @@
|
||||
"/{app_id}/delete": {
|
||||
"delete": {
|
||||
"tags": ["Apps"],
|
||||
"summary": "Delete App",
|
||||
"description": "Delete an existing app.",
|
||||
"summary": "Delete app",
|
||||
"description": "Delete an existing app",
|
||||
"operationId": "delete_app__app_id__delete_delete",
|
||||
"parameters": [
|
||||
{
|
||||
@@ -339,7 +339,7 @@
|
||||
"api_key": {
|
||||
"type": "string",
|
||||
"title": "Api Key",
|
||||
"description": "The Embedchain API key for App deployments.",
|
||||
"description": "The Embedchain API key for app deployments. You get the api key on the Embedchain platform by visiting [https://app.embedchain.ai](https://app.embedchain.ai)",
|
||||
"default": ""
|
||||
}
|
||||
},
|
||||
@@ -425,4 +425,3 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
22
docs/rest-api/add-data.mdx
Normal file
22
docs/rest-api/add-data.mdx
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
openapi: post /{app_id}/add
|
||||
---
|
||||
|
||||
<RequestExample>
|
||||
|
||||
```bash Request
|
||||
curl --request POST \
|
||||
--url http://localhost:8080/{app_id}/add \
|
||||
-d "source=https://www.forbes.com/profile/elon-musk" \
|
||||
-d "data_type=web_page"
|
||||
```
|
||||
|
||||
</RequestExample>
|
||||
|
||||
<ResponseExample>
|
||||
|
||||
```json Response
|
||||
{ "response": "fec7fe91e6b2d732938a2ec2e32bfe3f" }
|
||||
```
|
||||
|
||||
</ResponseExample>
|
||||
3
docs/rest-api/chat.mdx
Normal file
3
docs/rest-api/chat.mdx
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
openapi: post /{app_id}/chat
|
||||
---
|
||||
20
docs/rest-api/check-status.mdx
Normal file
20
docs/rest-api/check-status.mdx
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
openapi: get /ping
|
||||
---
|
||||
|
||||
<RequestExample>
|
||||
|
||||
```bash Request
|
||||
curl --request GET \
|
||||
--url http://localhost:8080/ping
|
||||
```
|
||||
|
||||
</RequestExample>
|
||||
|
||||
<ResponseExample>
|
||||
|
||||
```json Response
|
||||
{ "ping": "pong" }
|
||||
```
|
||||
|
||||
</ResponseExample>
|
||||
21
docs/rest-api/create.mdx
Normal file
21
docs/rest-api/create.mdx
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
openapi: post /create
|
||||
---
|
||||
|
||||
<RequestExample>
|
||||
|
||||
```bash Request
|
||||
curl --request POST \
|
||||
--url http://localhost:8080/create \
|
||||
-F "config=@/path/to/config.yaml"
|
||||
```
|
||||
|
||||
</RequestExample>
|
||||
|
||||
<ResponseExample>
|
||||
|
||||
```json Response
|
||||
{ "response": "App created successfully. App ID: {app_id}" }
|
||||
```
|
||||
|
||||
</ResponseExample>
|
||||
21
docs/rest-api/delete.mdx
Normal file
21
docs/rest-api/delete.mdx
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
openapi: delete /{app_id}/delete
|
||||
---
|
||||
|
||||
|
||||
<RequestExample>
|
||||
|
||||
```bash Request
|
||||
curl --request DELETE \
|
||||
--url http://localhost:8080/{app_id}/delete
|
||||
```
|
||||
|
||||
</RequestExample>
|
||||
|
||||
<ResponseExample>
|
||||
|
||||
```json Response
|
||||
{ "response": "App with id {app_id} deleted successfully." }
|
||||
```
|
||||
|
||||
</ResponseExample>
|
||||
22
docs/rest-api/deploy.mdx
Normal file
22
docs/rest-api/deploy.mdx
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
openapi: post /{app_id}/deploy
|
||||
---
|
||||
|
||||
|
||||
<RequestExample>
|
||||
|
||||
```bash Request
|
||||
curl --request POST \
|
||||
--url http://localhost:8080/{app_id}/deploy \
|
||||
-d "api_key=ec-xxxx"
|
||||
```
|
||||
|
||||
</RequestExample>
|
||||
|
||||
<ResponseExample>
|
||||
|
||||
```json Response
|
||||
{ "response": "App deployed successfully." }
|
||||
```
|
||||
|
||||
</ResponseExample>
|
||||
33
docs/rest-api/get-all-apps.mdx
Normal file
33
docs/rest-api/get-all-apps.mdx
Normal file
@@ -0,0 +1,33 @@
|
||||
---
|
||||
openapi: get /apps
|
||||
---
|
||||
|
||||
<RequestExample>
|
||||
|
||||
```bash Request
|
||||
curl --request GET \
|
||||
--url http://localhost:8080/apps
|
||||
```
|
||||
|
||||
</RequestExample>
|
||||
|
||||
<ResponseExample>
|
||||
|
||||
```json Response
|
||||
{
|
||||
"results": [
|
||||
{
|
||||
"config": "config1.yaml",
|
||||
"id": 1,
|
||||
"app_id": "app1"
|
||||
},
|
||||
{
|
||||
"config": "config2.yaml",
|
||||
"id": 2,
|
||||
"app_id": "app2"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</ResponseExample>
|
||||
28
docs/rest-api/get-data.mdx
Normal file
28
docs/rest-api/get-data.mdx
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
openapi: get /{app_id}/data
|
||||
---
|
||||
|
||||
<RequestExample>
|
||||
|
||||
```bash Request
|
||||
curl --request GET \
|
||||
--url http://localhost:8080/{app_id}/data
|
||||
```
|
||||
|
||||
</RequestExample>
|
||||
|
||||
<ResponseExample>
|
||||
|
||||
```json Response
|
||||
{
|
||||
"results": [
|
||||
{
|
||||
"data_type": "web_page",
|
||||
"data_value": "https://www.forbes.com/profile/elon-musk/",
|
||||
"metadata": "null"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</ResponseExample>
|
||||
87
docs/rest-api/getting-started.mdx
Normal file
87
docs/rest-api/getting-started.mdx
Normal file
@@ -0,0 +1,87 @@
|
||||
---
|
||||
title: "🌍 Getting Started"
|
||||
---
|
||||
|
||||
## Quickstart
|
||||
|
||||
To use Embedchain as a REST API service, run the following command:
|
||||
|
||||
```bash
|
||||
docker run --name embedchain -p 8080:8080 embedchain/app:rest-api-latest
|
||||
```
|
||||
|
||||
Navigate to [http://localhost:8080/docs](http://localhost:8080/docs) to interact with the API. There is a full-fledged Swagger docs playground with all the information about the API endpoints.
|
||||
|
||||

|
||||
|
||||
## Creating your first App
|
||||
|
||||
App requires an `app_id` to be created. The `app_id` is a unique identifier for your app. 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.
|
||||
|
||||
For example, create a `config.yaml` file (adjust according to your requirements):
|
||||
|
||||
```yaml
|
||||
app:
|
||||
config:
|
||||
id: "default-app"
|
||||
|
||||
llm:
|
||||
provider: openai
|
||||
config:
|
||||
model: "gpt-3.5-turbo"
|
||||
temperature: 0.5
|
||||
max_tokens: 1000
|
||||
top_p: 1
|
||||
stream: false
|
||||
template: |
|
||||
Use the following pieces of context to answer the query at the end.
|
||||
If you don't know the answer, just say that you don't know, don't try to make up an answer.
|
||||
|
||||
$context
|
||||
|
||||
Query: $query
|
||||
|
||||
Helpful Answer:
|
||||
|
||||
vectordb:
|
||||
provider: chroma
|
||||
config:
|
||||
collection_name: "rest-api-app"
|
||||
dir: db
|
||||
allow_reset: true
|
||||
|
||||
embedder:
|
||||
provider: openai
|
||||
config:
|
||||
model: "text-embedding-ada-002"
|
||||
```
|
||||
|
||||
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).
|
||||
|
||||
Now, you can upload this config file in the request body.
|
||||
|
||||
**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.
|
||||
|
||||
| Keys | Providers |
|
||||
| -------------------------- | ------------------------------ |
|
||||
| `OPENAI_API_KEY ` | OpenAI, Azure OpenAI, Jina etc |
|
||||
| `OPENAI_API_TYPE` | Azure OpenAI |
|
||||
| `OPENAI_API_BASE` | Azure OpenAI |
|
||||
| `OPENAI_API_VERSION` | Azure OpenAI |
|
||||
| `COHERE_API_KEY` | Cohere |
|
||||
| `ANTHROPIC_API_KEY` | Anthropic |
|
||||
| `JINACHAT_API_KEY` | Jina |
|
||||
| `HUGGINGFACE_ACCESS_TOKEN` | Huggingface |
|
||||
| `REPLICATE_API_TOKEN` | LLAMA2 |
|
||||
|
||||
To add env variables, you can simply run the docker command with the `-e` flag.
|
||||
|
||||
For example,
|
||||
|
||||
```bash
|
||||
docker run --name embedchain -p 8080:8080 -e OPENAI_API_KEY=<YOUR_OPENAI_API_KEY> embedchain/app:rest-api-latest
|
||||
```
|
||||
|
||||
If you run into issues, please feel free to contact us using below links:
|
||||
|
||||
<Snippet file="get-help.mdx" />
|
||||
21
docs/rest-api/query.mdx
Normal file
21
docs/rest-api/query.mdx
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
openapi: post /{app_id}/query
|
||||
---
|
||||
|
||||
<RequestExample>
|
||||
|
||||
```bash Request
|
||||
curl --request POST \
|
||||
--url http://localhost:8080/{app_id}/query \
|
||||
-d "query=who is Elon Musk?"
|
||||
```
|
||||
|
||||
</RequestExample>
|
||||
|
||||
<ResponseExample>
|
||||
|
||||
```json Response
|
||||
{ "response": "Net worth of Elon Musk is $218 Billion." }
|
||||
```
|
||||
|
||||
</ResponseExample>
|
||||
Reference in New Issue
Block a user