diff --git a/appinfo/routes.php b/appinfo/routes.php index 1022f74c..afbebcc4 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -35,6 +35,7 @@ ['name' => 'assistantApi#getOutputFilePreview', 'url' => '/api/{apiVersion}/task/{ocpTaskId}/output-file/{fileId}/preview', 'verb' => 'GET', 'requirements' => $requirements], ['name' => 'assistantApi#getOutputFile', 'url' => '/api/{apiVersion}/task/{ocpTaskId}/output-file/{fileId}/download', 'verb' => 'GET', 'requirements' => $requirements], ['name' => 'assistantApi#runFileAction', 'url' => '/api/{apiVersion}/file-action/{fileId}/{taskTypeId}', 'verb' => 'POST', 'requirements' => $requirements], + ['name' => 'assistantApi#getAssistantFolderPath', 'url' => '/api/{apiVersion}/assistant-folder-path', 'verb' => 'GET', 'requirements' => $requirements], ['name' => 'chattyLLM#newSession', 'url' => '/chat/sessions', 'verb' => 'POST', 'postfix' => 'restful'], ['name' => 'chattyLLM#updateChatSession', 'url' => '/chat/sessions/{sessionId}', 'verb' => 'PUT', 'postfix' => 'restful'], diff --git a/lib/Controller/AssistantApiController.php b/lib/Controller/AssistantApiController.php index 6f027072..b49099f1 100644 --- a/lib/Controller/AssistantApiController.php +++ b/lib/Controller/AssistantApiController.php @@ -447,4 +447,24 @@ public function runFileAction(int $fileId, string $taskTypeId): DataResponse { return new DataResponse(['error' => $e->getMessage()], Http::STATUS_BAD_REQUEST); } } + + /** + * Get the assistant folder's path + * + * Returns the assistant folder's path inside the user's home mount + * + * @return DataResponse|DataResponse + * + * 200: The path is returned in the form: //files/Assistant + */ + #[NoAdminRequired] + #[NoCsrfRequired] + public function getAssistantFolderPath(): DataResponse { + if ($this->userId === null) { + return new DataResponse(['error' => 'User should be logged in', Http::STATUS_UNAUTHORIZED]); + } + + $folder = $this->assistantService->getAssistantDataFolder($this->userId); + return new DataResponse(['path' => $folder->getPath()]); + } } diff --git a/openapi.json b/openapi.json index 8793d83b..37de5735 100644 --- a/openapi.json +++ b/openapi.json @@ -2743,6 +2743,151 @@ } } }, + "/ocs/v2.php/apps/assistant/api/{apiVersion}/assistant-folder-path": { + "get": { + "operationId": "assistant_api-get-assistant-folder-path", + "summary": "Get the assistant folder's path", + "description": "Returns the assistant folder's path inside the user's home mount", + "tags": [ + "assistant_api" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "apiVersion", + "in": "path", + "required": true, + "schema": { + "type": "string", + "enum": [ + "v1" + ], + "default": "v1" + } + }, + { + "name": "OCS-APIRequest", + "in": "header", + "description": "Required to be true for the API request to pass", + "required": true, + "schema": { + "type": "boolean", + "default": true + } + } + ], + "responses": { + "200": { + "description": "The path is returned in the form: //files/Assistant", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": { + "type": "object", + "required": [ + "path" + ], + "properties": { + "path": { + "type": "string" + } + } + } + } + } + } + } + } + } + }, + "401": { + "description": "Current user is not logged in", + "content": { + "application/json": { + "schema": { + "anyOf": [ + { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": { + "type": "object", + "required": [ + "error" + ], + "properties": { + "error": { + "type": "string" + } + } + } + } + } + } + }, + { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + ] + } + } + } + } + } + } + }, "/ocs/v2.php/apps/assistant/chat/sessions": { "post": { "operationId": "chattyllm-new-session-restful",