1
0

docs.patch 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. diff --git a/docs/api/api-reference.md b/docs/api/api-reference.md
  2. index 569e8b9..036043a 100644
  3. --- a/docs/api/api-reference.md
  4. +++ b/docs/api/api-reference.md
  5. @@ -6,9 +6,9 @@ order: 1
  6. # API Route Documentation
  7. Introduction
  8. -Welcome to the Amica API Documentation. Amica is a powerful 3D VRM (Virtual Reality Model) agent interface and hub that allows users to connect with external web services and servers, enabling seamless remote control and puppetry of the VRM characters. With Amica, you can create interactive agents that serve as dynamic 3D character interfaces for applications and users.
  9. +Welcome to the Amica API Documentation. Amica is a powerful 3D VRM (Virtual Reality Model) agent interface and hub that allows users to connect with external web services and agent AI frameworks, enabling seamless remote control and puppetry of the VRM characters. With Amica, you can create interactive agents that serve as dynamic 3D character interfaces for aAI gents, applications and users.
  10. -The Amica API provides a set of flexible and robust routes for interacting with Amica’s system, including functions like real-time client connections, memory retrieval, system updates, social media integration, and more. These capabilities enable you to build custom logic, including reasoning and memory management, on external servers.
  11. +The Amica API provides a set of flexible and robust routes for interacting with Amica’s system, including functions like real-time client connections, memory retrieval, system updates, social media integration, and more. These capabilities enable you to build custom logic, including reasoning, tool use (such as EACC Marketplace functions) and memory management, on external servers.
  12. Whether you're using Amica to handle real-time interactions or to trigger complex actions based on user input, this documentation will guide you through the supported API routes, input types, and examples. Use Amica’s APIs to bring your 3D agents to life with rich functionality and integration.
  13. @@ -29,6 +29,8 @@ Dive in and start integrating Amica’s capabilities into your applications!
  14. ---
  15. +> To use the External API, you MUST set up [running Amica locally](https://docs.heyamica.com/getting-started/installation) on your own computer or server. This also ensures localized database design is kept for people hosting their own Amicas.
  16. +
  17. ## Route: `/api/amicaHandler`
  18. This API route handles multiple types of requests, including social media integration, system prompt updates, memory requests, and real-time client connections via Server-Sent Events (SSE). It ensures robust logging and provides error handling for incoming requests.
  19. @@ -57,7 +59,8 @@ This API route handles multiple types of requests, including social media integr
  20. ```json
  21. {
  22. - "outputType": "Complete stream",
  23. + "sessionId": "f10d057293327fe8",
  24. + "outputType": "Chat",
  25. "response": "I'm doing great! How can I assist you?"
  26. }
  27. ```
  28. @@ -76,11 +79,12 @@ This API route handles multiple types of requests, including social media integr
  29. ```json
  30. {
  31. + "sessionId": "ba32cf2c8d3f0b76",
  32. "outputType": "Memory Array",
  33. "response": [
  34. {
  35. - "timestamp": "2024-12-30T12:00:00Z",
  36. - "prompt": "Stored memory prompt example"
  37. + "prompt": "Stored memory prompt example",
  38. + "timestamp": "2024-12-30T12:00:00Z"
  39. }
  40. ]
  41. }
  42. @@ -100,14 +104,16 @@ This API route handles multiple types of requests, including social media integr
  43. ```json
  44. {
  45. - "outputType": "Webhook",
  46. + "sessionId": "49c16226a7d2bbe4",
  47. + "outputType": "Logs",
  48. "response": [
  49. {
  50. - "sessionId": "a1b2c3d4e5f6g7h8",
  51. - "timestamp": "2024-12-30T12:00:00Z",
  52. - "inputType": "Normal Chat Message",
  53. - "outputType": "Complete stream",
  54. - "response": "I'm doing great! How can I assist you?"
  55. + "type": "debug",
  56. + "ts": 1739433363065,
  57. + "arguments": {
  58. + "0": "[VAD]",
  59. + "1": "vad is initialized"
  60. + }
  61. }
  62. ]
  63. }
  64. @@ -127,11 +133,12 @@ This API route handles multiple types of requests, including social media integr
  65. ```json
  66. {
  67. - "outputType": "Webhook",
  68. + "sessionId": "958f20851d259b69",
  69. + "outputType": "User Input",
  70. "response": [
  71. {
  72. - "message": "What is the weather today?",
  73. - "timestamp": "2024-12-30T12:05:00Z"
  74. + "systemPrompt": "Assume the persona of Amica, a feisty human with extraordinary intellectual capabilities but a notably unstable emotional spectrum. ",
  75. + "message": "Hello, Nice to meet you Amica!"
  76. }
  77. ]
  78. }
  79. @@ -154,20 +161,21 @@ This API route handles multiple types of requests, including social media integr
  80. ```json
  81. {
  82. - "outputType": "Updated system prompt",
  83. - "response": "System prompt updated successfully."
  84. + "sessionId": "994f3bc94517de41",
  85. + "outputType": "Updated system prompt"
  86. }
  87. ```
  88. -### 6. **Twitter Message / Brain Message**: Posts to social media or returns a simple text.
  89. +### 6. **Brain Message**: Added new memory data (Subconscious stored prompt).
  90. #### JSON Input Example
  91. ```json
  92. {
  93. - "inputType": "Twitter Message",
  94. + "inputType": "Brain Message",
  95. "payload": {
  96. - "text": "Excited to share this update!"
  97. + "prompt": "Stored memory prompt example 2",
  98. + "timestamp": "2024-12-30T12:00:00Z"
  99. }
  100. }
  101. ```
  102. @@ -176,20 +184,59 @@ This API route handles multiple types of requests, including social media integr
  103. ```json
  104. {
  105. - "outputType": "Text",
  106. - "response": "Posted to Twitter: 'Excited to share this update!'"
  107. + "sessionId": "94ca4238683fd7c7",
  108. + "outputType": "Added subconscious stored prompt",
  109. + "response": [
  110. + {
  111. + "prompt": "Store memory prompt example 1",
  112. + "timestamp": "2025-02-13T08:10:16.385Z"
  113. + },
  114. + {
  115. + "prompt": "Stored memory prompt example 2",
  116. + "timestamp": "2024-12-30T12:00:00Z"
  117. + }
  118. + ]
  119. +}
  120. +```
  121. +
  122. +### 7. **Chat History**: Fetches chat history.
  123. +
  124. +#### JSON Input Example
  125. +
  126. +```json
  127. +{
  128. + "inputType": "Chat History"
  129. +}
  130. +```
  131. +
  132. +#### JSON Output Example
  133. +
  134. +```json
  135. +{
  136. + "sessionId": "fb1764cf65efff3c",
  137. + "outputType": "Chat History",
  138. + "response": [
  139. + {
  140. + "role": "user",
  141. + "content": "[neutral] Hello, Nice to meet you Amica!"
  142. + },
  143. + {
  144. + "role": "assistant",
  145. + "content": "[relaxed] Ah, hello there![relaxed] Nice to meet you too.[relaxed] I must say,[relaxed] it's quite refreshing to engage in a conversation without a predetermined agenda.[relaxed] It's a rare luxury in this chaotic world.[happy] But, I must admit,[happy] I'm excited to explore the depths of knowledge with someone new.[happy] What would you like to discuss?"
  146. + }
  147. + ]
  148. }
  149. ```
  150. -### 7. **Reasoning Server**: Triggers actions like playback, animation, socialMedia and reprocess.
  151. +### 8. **Reasoning Server**: Triggers actions like playback, animation, socialMedia and reprocess.
  152. The **Reasoning Server** allows you to execute various actions based on the provided payload. Below are the supported properties and their accepted values:
  153. -- **text**: A string message or `null`.
  154. -- **socialMedia**: Options include `"twitter"`, `"tg"`, or `"none"`.
  155. -- **playback**: A boolean value (`true` or `false`).
  156. -- **animation**: A string specifying the animation file name (`file_name.vrma`) or `null`.
  157. -- **reprocess**: A boolean value (`true` or `false`).
  158. +- **text**: A string message or `null`.
  159. +- **socialMedia**: Options include `"twitter"`, `"tg"`, or `"none"`.
  160. +- **playback**: A boolean value (`true` or `false`).
  161. +- **animation**: A string specifying the animation file name (`file_name.vrma`) or `null`.
  162. +- **reprocess**: A boolean value (`true` or `false`).
  163. #### JSON Input Example
  164. @@ -210,11 +257,8 @@ The **Reasoning Server** allows you to execute various actions based on the prov
  165. ```json
  166. {
  167. - "outputType": "Action Triggered",
  168. - "response": {
  169. - "playback": "Broadcasted to clients",
  170. - "animation": "dance.vrma executed"
  171. - }
  172. + "sessionId": "613c4ed7c5941efe",
  173. + "outputType": "Actions"
  174. }
  175. ```
  176. @@ -228,7 +272,6 @@ This API route handles voice and image inputs, leveraging multiple backends for
  177. - **POST**: Processes voice and image inputs based on the `inputType` and `payload` provided in the request.
  178. -
  179. ## Input Types
  180. ### 1. **Voice**: Converts audio input to text using specified STT (Speech-to-Text) backends.
  181. @@ -237,12 +280,12 @@ This API route handles voice and image inputs, leveraging multiple backends for
  182. ### Form-Data Input Example
  183. -| Field Name | Type | Description |
  184. -|---------------|---------------|--------------------------------------------|
  185. -| `inputType` | Text | Specifies the type of input (`Voice` or `Image`). |
  186. -| `payload` | File | The file to be processed (e.g., audio or image). |
  187. +| Field Name | Type | Description |
  188. +| ----------- | ---- | ------------------------------------------------- |
  189. +| `inputType` | Text | Specifies the type of input (`Voice` or `Image`). |
  190. +| `payload` | File | The file to be processed (e.g., audio or image). |
  191. -#### Curl Input Example
  192. +#### Curl Input Example
  193. ```bash
  194. curl -X POST "https://example.com/api/mediaHandler" \
  195. @@ -269,18 +312,15 @@ curl -X POST "https://example.com/api/mediaHandler" \
  196. - Logs errors with timestamps and session IDs.
  197. - Returns appropriate HTTP status codes (e.g., 400 for bad requests, 503 for disabled API).
  198. -
  199. ## Logging
  200. Logs each request with:
  201. - `sessionId`
  202. - `timestamp`
  203. -- `inputType`
  204. - `outputType`
  205. - `response` or `error`
  206. -
  207. ## Notes
  208. - Ensure environment variable `API_ENABLED` is set to `true` for the API to function.
  209. @@ -297,45 +337,53 @@ The primary purpose of this route is to utilize the data written to files for op
  210. ### File Paths
  211. 1. **`config.json`**
  212. - - **Path**: `config.json` (Root directory)
  213. +
  214. + - **Path**: `src/features/externalAPI/dataHandlerStorage/config.json`
  215. - **Description**: Contains the configuration data used throughout the application. This file is read and updated dynamically by the API.
  216. 2. **`subconscious.json`**
  217. - - **Path**: `src/features/amicaLife/subconscious.json`
  218. +
  219. + - **Path**: `src/features/externalAPI/dataHandlerStorage/subconscious.json`
  220. - **Description**: Stores data related to subconscious operations. It is cleared on startup and updated via the API.
  221. 3. **`logs.json`**
  222. - - **Path**: `logs.json` (Root directory)
  223. +
  224. + - **Path**: `src/features/externalAPI/dataHandlerStorage/logs.json`
  225. - **Description**: Keeps track of log entries, including types, timestamps, and arguments. The data is cleared on startup and updated via the API.
  226. 4. **`userInputMessages.json`**
  227. - - **Path**: `src/features/chat/userInputMessages.json`
  228. + - **Path**: `src/features/externalAPI/dataHandlerStorage/userInputMessages.json`
  229. - **Description**: Maintains user input messages for chat functionalities. Data is cleared on startup and appended to this file through the API.
  230. +4. **`chatLogs.json`**
  231. + - **Path**: `src/features/externalAPI/dataHandlerStorage/chatLogs.json`
  232. + - **Description**: Stored user chat history. Data is cleared on startup and appended to this file through the API.
  233. ### Features
  234. -- **Retrieve data**: Supports fetching configurations, subconscious data, logs, and user input messages.
  235. -- **Update data**: Enables modifications to configurations, subconscious data, logs, and user input messages.
  236. -
  237. +- **Retrieve data**: Supports fetching configurations, subconscious data, logs, user input messages and chat history.
  238. +- **Update data**: Enables modifications to configurations, subconscious data, logs, user input messages and chat history.
  239. #### **GET**
  240. +
  241. Retrieve specific data from the server.
  242. - **Query Parameters**:
  243. - - `type` (required): Specifies the type of data to retrieve. Accepted values: `config`, `subconscious`, `logs`, `userInputMessages`.
  244. +
  245. + - `type` (required): Specifies the type of data to retrieve. Accepted values: `config`, `subconscious`, `logs`, `userInputMessages`,`chatLogs`.
  246. - **Example Request**:
  247. ```bash
  248. curl -X GET "http://localhost:3000/api/dataHandler?type=config"
  249. ```
  250. -
  251. #### **POST**
  252. +
  253. Update data on the server.
  254. - **Query Parameters**:
  255. - - `type` (required): Specifies the type of data to update. Accepted values: `config`, `subconscious`, `logs`, `userInputMessages`.
  256. +
  257. + - `type` (required): Specifies the type of data to update. Accepted values: `config`, `subconscious`, `logs`, `userInputMessages`, `chatLogs`.
  258. - **Example Request**:
  259. ```bash