add: API server(#422)
Add an example of api server so that devs can quickly get up a bot running along with its api
This commit is contained in:
committed by
GitHub
parent
d51c508b40
commit
a86deb2675
46
docs/examples/api_server.mdx
Normal file
46
docs/examples/api_server.mdx
Normal file
@@ -0,0 +1,46 @@
|
||||
---
|
||||
title: '🌍 API Server'
|
||||
---
|
||||
|
||||
### 🐳 Docker Setup
|
||||
|
||||
- Open variables.env, and edit it to add your 🔑 `OPENAI_API_KEY`.
|
||||
- To setup your api server using docker, run the following command inside this folder using your terminal.
|
||||
|
||||
```bash
|
||||
docker-compose up --build
|
||||
```
|
||||
|
||||
📝 Note: The build command might take a while to install all the packages depending on your system resources.
|
||||
|
||||
### 🚀 Usage Instructions
|
||||
|
||||
- Your api server is running on [http://localhost:5000/](http://localhost:5000/)
|
||||
- To use the api server, make an api call to the endpoints `/add` and `/query` using the json formats discussed below.
|
||||
- To add data sources to the bot:
|
||||
```json
|
||||
// Request
|
||||
{
|
||||
"data_type": "your_data_type_here",
|
||||
"url_or_text": "your_url_or_text_here"
|
||||
}
|
||||
|
||||
// Response
|
||||
{
|
||||
"data": "Added data_type: url_or_text"
|
||||
}
|
||||
```
|
||||
- To ask questions from the bot:
|
||||
```json
|
||||
// Request
|
||||
{
|
||||
"question": "your_question_here"
|
||||
}
|
||||
|
||||
// Response
|
||||
{
|
||||
"data": "your_answer_here"
|
||||
}
|
||||
```
|
||||
|
||||
🎉 Happy Chatting! 🎉
|
||||
@@ -36,7 +36,7 @@
|
||||
},
|
||||
{
|
||||
"group": "Examples",
|
||||
"pages": ["examples/full_stack"]
|
||||
"pages": ["examples/full_stack", "examples/api_server"]
|
||||
},
|
||||
{
|
||||
"group": "Contribution Guidelines",
|
||||
|
||||
Reference in New Issue
Block a user