diff --git a/API-Docs.md b/API-Docs.md new file mode 100644 index 0000000..1d1a9ae --- /dev/null +++ b/API-Docs.md @@ -0,0 +1,105 @@ +# 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 contains +- [Base line for all API calls]() +- [API Requests]() + - [Add tool]() + - [AI querry]() + +## 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 + +```jsonc +{ + "type": "ADD_TOOL", // This is a enum value from the [API endpoints enum]() + "data": {} // This JSON object contains the expected data for the API endpoint +} +``` + +this package can ether be compressed using gzip or sent raw +OPS! currently encryption and any sort of autnetication is not avalible + +## API Requests +### Add a 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 + +Tool json +```jsonc +{ + "name": "a_tool_name", // The name for the tool, this is used for the AI and the backend to know where to send the required tool use + "description": "A description for the tool that describes what it dose", // A simple description for the tool + "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 + "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 + "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 +} +``` + +Example of the in built tool [`get_current_date`](https://server.4zellen.se:3000/Zacharias/chat_thing/src/branch/master/src/main/java/me/zacharias/chat/TimeTool.java) if it where to be defined with this API +```json +{ + "name": "get_current_date", + "description": "Get the current date", + "required": [], + "responce": "string" +} +``` + +view [Tool Handeling]() to see how this is done in code + +### Send a question +**`Endpoint: QUERRY`** + +This is probobly the simplest API endpoint since the data is just the querry + +```jsonc +{ + "type": "QUERRY", // The API endpoint based on the [API endpoints enum]() + "data": { + "message": "The querry" // the querry/question + } +} +``` + +That is the whole API data package to request a qurry, this then get a responce from the `RESPONCE` API endpoint + +#### Advance options +If you know that your endpoint requires an `tool` call, you can add the `"tools"` json key to the data object + +```jsonc +{ + "type": "QUERRY", // The API endpoint based on the [API endpoints enum]() + "data": { + "message": "The querry", // the querry/question + "tools": [] // This array contains all the tool's you whant to call + } +} +``` + +example + +```jsonc +{ + "type": "QUERRY", // The API endpoint based on the [API endpoints enum]() + "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 + "tools": ["get_current_date"] + } +} +``` + +example of what `%0` whuld be in a call to `get_current_date` +```jsonc +{ + "result": "Thu Feb 20 20:30:05 CET 2025", // the responce from the tool + "tool": "get_current_date" // what tool was used +} +```