Update API Docs
40
API-Docs.md
40
API-Docs.md
@@ -1,15 +1,17 @@
|
|||||||
# The API requires the system to be started as a [server](https://server.4zellen.se:3000)
|
# The API requires the system to be started as a [server](https://server.4zellen.se:3000)
|
||||||
|
|
||||||
This page contains the API calls but not code examples for the API calls on how to handle the request and the potencial calls
|
This page provides API calls (without code examples) and describes how to handle requests and potential calls.
|
||||||
|
|
||||||
|
This page assumes a basic knowledge of programming, API usage, and JSON.
|
||||||
|
|
||||||
This page contains
|
This page contains
|
||||||
- [Base line for all API calls](https://server.4zellen.se:3000/Zacharias/chat_thing/wiki/API-Docs#base-line-for-all-api-calls)
|
- [Base line for all API calls](https://server.4zellen.se:3000/Zacharias/chat_thing/wiki/API-Docs#base-line-for-all-api-calls)
|
||||||
- [API Requests](https://server.4zellen.se:3000/Zacharias/chat_thing/wiki/API-Docs#api-requests)
|
- [API Requests](https://server.4zellen.se:3000/Zacharias/chat_thing/wiki/API-Docs#api-requests)
|
||||||
- [Add tool](https://server.4zellen.se:3000/Zacharias/chat_thing/wiki/API-Docs#api-requests)
|
- [Add tool](https://server.4zellen.se:3000/Zacharias/chat_thing/wiki/API-Docs#api-requests)
|
||||||
- [AI querry](https://server.4zellen.se:3000/Zacharias/chat_thing/wiki/API-Docs#send-a-question)
|
- [AI query](https://server.4zellen.se:3000/Zacharias/chat_thing/wiki/API-Docs#send-a-question)
|
||||||
|
|
||||||
## Base line for all API calls
|
## Base line for all API calls
|
||||||
This is a TCP API that means that it needs a json data package containing the "enpoint" aswell as the data
|
This API uses TCP and requires a JSON data package containing the 'endpoint' and the corresponding data.
|
||||||
|
|
||||||
```jsonc
|
```jsonc
|
||||||
{
|
{
|
||||||
@@ -19,13 +21,13 @@ This is a TCP API that means that it needs a json data package containing the "e
|
|||||||
```
|
```
|
||||||
|
|
||||||
this package can ether be compressed using gzip or sent raw
|
this package can ether be compressed using gzip or sent raw
|
||||||
OPS! currently encryption and any sort of autnetication is not avalible
|
Note: Currently, encryption and authentication are not available.
|
||||||
|
|
||||||
## API Requests
|
## API Requests
|
||||||
### Add a tool
|
### Add a tool
|
||||||
**`Endpoint: ADD_TOOL`**
|
**`Endpoint: ADD_TOOL`**
|
||||||
|
|
||||||
To add a tool you need to send a tool package and make sure you have set things up to handle the tool calls from the AI
|
To add a tool, send a tool package and ensure that your system is set up to handle tool calls from the AI.
|
||||||
|
|
||||||
Tool json
|
Tool json
|
||||||
```jsonc
|
```jsonc
|
||||||
@@ -34,12 +36,12 @@ Tool json
|
|||||||
"description": "A description for the tool that describes what it dose", // A simple description for the tool
|
"description": "A description for the tool that describes what it dose", // A simple description for the tool
|
||||||
"arguments": [
|
"arguments": [
|
||||||
{
|
{
|
||||||
"type": "string", // This is an enum that can be `string`, ìnt`, `boolean`, `float`, `double`, `char`. reson for the float and the double is that the server is made with Java so it has two difrent presitions
|
"type": "string", // This is an enum value that can be `string`, ìnt`, `boolean`, `float`, `double`, `char`. reson for the float and the double is that the server is made with Java so it has two difrent presitions
|
||||||
"name": "a_name_for_the_argument" // This is the argument variable name, so this is what you whuld refer to in your code to read the value
|
"name": "a_name_for_the_argument" // This is the argument variable name, so this is what you whuld refer to in your code to read the value
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"required": ["a_name_for_the_argument"], // An array containing the argument name's to indicate witch is required and witch isn't
|
"required": ["a_name_for_the_argument"], // An array containing the argument name's to indicate witch is required and witch isn't
|
||||||
"responce": "void" // This is an enum of what is the expected responce type, this is mostly only for the backend and isn't required but helps to verify if the data returned is correct before giving it to the AI, the enum values are the same as the argument type but void is also accepted
|
"response": "void" // This is an enum of what is the expected response type, this is mostly only for the backend and isn't required but helps to verify if the data returned is correct before giving it to the AI, the enum values are the same as the argument type but void is also accepted
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -49,36 +51,36 @@ Example of the in built tool [`get_current_date`](https://server.4zellen.se:3000
|
|||||||
"name": "get_current_date",
|
"name": "get_current_date",
|
||||||
"description": "Get the current date",
|
"description": "Get the current date",
|
||||||
"required": [],
|
"required": [],
|
||||||
"responce": "string"
|
"response": "string"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
view [Tool Handeling]() to see how this is done in code
|
view [Tool Handeling]() to see how this is done in code
|
||||||
|
|
||||||
### Send a question
|
### Send a question
|
||||||
**`Endpoint: QUERRY`**
|
**`Endpoint: QUERY`**
|
||||||
|
|
||||||
This is probobly the simplest API endpoint since the data is just the querry
|
This is probably the simplest API endpoint since it only requires the query data.
|
||||||
|
|
||||||
```jsonc
|
```jsonc
|
||||||
{
|
{
|
||||||
"type": "QUERRY", // The API endpoint based on the [API endpoints enum]()
|
"type": "QUERY", // The API endpoint based on the [API endpoints enum]()
|
||||||
"data": {
|
"data": {
|
||||||
"message": "The querry" // the querry/question
|
"message": "The query" // the query/question
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
That is the whole API data package to request a qurry, this then get a responce from the `RESPONCE` API endpoint
|
That is the whole API data package to request a qurry, this then get a response from the `RESPONSE` API endpoint
|
||||||
|
|
||||||
#### Advance options
|
#### Advance options
|
||||||
If you know that your endpoint requires an `tool` call, you can add the `"tools"` json key to the data object
|
If your query requires a tool call, include a "tools" key in the data object. This key should contain an array of the tools that the query requires.
|
||||||
|
|
||||||
```jsonc
|
```jsonc
|
||||||
{
|
{
|
||||||
"type": "QUERRY", // The API endpoint based on the [API endpoints enum]()
|
"type": "QUERY", // The API endpoint based on the [API endpoints enum]()
|
||||||
"data": {
|
"data": {
|
||||||
"message": "The querry", // the querry/question
|
"message": "The query", // the query/question
|
||||||
"tools": [] // This array contains all the tool's you whant to call
|
"tools": [] // This array contains all the tool's you whant to call
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,9 +90,9 @@ example
|
|||||||
|
|
||||||
```jsonc
|
```jsonc
|
||||||
{
|
{
|
||||||
"type": "QUERRY", // The API endpoint based on the [API endpoints enum]()
|
"type": "QUERY", // The API endpoint based on the [API endpoints enum]()
|
||||||
"data": {
|
"data": {
|
||||||
"message": "This is the current data %0", // the `%0` is used to spesify where the first tool's responce shuld be put, the responces is in a json format and if not specified the responce will always be put in json format at the start
|
"message": "This is the current data %0", // the `%X` is used to spesify where the X'th tool's response shuld be put, the responses is in a json format and if not specified the response will always be put in json format at the start
|
||||||
"tools": ["get_current_date"]
|
"tools": ["get_current_date"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -99,7 +101,7 @@ example
|
|||||||
example of what `%0` whuld be in a call to `get_current_date`
|
example of what `%0` whuld be in a call to `get_current_date`
|
||||||
```jsonc
|
```jsonc
|
||||||
{
|
{
|
||||||
"result": "Thu Feb 20 20:30:05 CET 2025", // the responce from the tool
|
"result": "Thu Feb 20 20:30:05 CET 2025", // the response from the tool
|
||||||
"tool": "get_current_date" // what tool was used
|
"tool": "get_current_date" // what tool was used
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user