Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
20 changes: 20 additions & 0 deletions lib/Controller/AssistantApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,4 +447,24 @@
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<Http::STATUS_OK, array{path: string}, array{}>|DataResponse<Http::STATUS_UNAUTHORIZED, array{error: string}, array{}>

Check failure on line 456 in lib/Controller/AssistantApiController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable33

InvalidReturnType

lib/Controller/AssistantApiController.php:456:13: InvalidReturnType: The declared return type 'OCP\AppFramework\Http\DataResponse<200|401, array{error?: string, path?: string}, array<never, never>>' for OCA\Assistant\Controller\AssistantApiController::getAssistantFolderPath is incorrect, got 'OCP\AppFramework\Http\DataResponse<200, array{0?: 401, error?: 'User should be logged in', path?: string}, array<never, never>>' (see https://psalm.dev/011)

Check failure on line 456 in lib/Controller/AssistantApiController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable34

InvalidReturnType

lib/Controller/AssistantApiController.php:456:13: InvalidReturnType: The declared return type 'OCP\AppFramework\Http\DataResponse<200|401, array{error?: string, path?: string}, array<never, never>>' for OCA\Assistant\Controller\AssistantApiController::getAssistantFolderPath is incorrect, got 'OCP\AppFramework\Http\DataResponse<200, array{0?: 401, error?: 'User should be logged in', path?: string}, array<never, never>>' (see https://psalm.dev/011)

Check failure on line 456 in lib/Controller/AssistantApiController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-master

InvalidReturnType

lib/Controller/AssistantApiController.php:456:13: InvalidReturnType: The declared return type 'OCP\AppFramework\Http\DataResponse<200|401, array{error?: string, path?: string}, array<never, never>>' for OCA\Assistant\Controller\AssistantApiController::getAssistantFolderPath is incorrect, got 'OCP\AppFramework\Http\DataResponse<200, array{0?: 401, error?: 'User should be logged in', path?: string}, array<never, never>>' (see https://psalm.dev/011)
*
* 200: The path is returned in the form: /<userId>/files/Assistant
*/
#[NoAdminRequired]
#[NoCsrfRequired]
public function getAssistantFolderPath(): DataResponse {
if ($this->userId === null) {
return new DataResponse(['error' => 'User should be logged in', Http::STATUS_UNAUTHORIZED]);

Check failure on line 464 in lib/Controller/AssistantApiController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable33

InvalidReturnStatement

lib/Controller/AssistantApiController.php:464:11: InvalidReturnStatement: The inferred type 'OCP\AppFramework\Http\DataResponse<200, array{0: 401, error: 'User should be logged in'}, array<never, never>>' does not match the declared return type 'OCP\AppFramework\Http\DataResponse<200|401, array{error?: string, path?: string}, array<never, never>>' for OCA\Assistant\Controller\AssistantApiController::getAssistantFolderPath (see https://psalm.dev/128)

Check failure on line 464 in lib/Controller/AssistantApiController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable34

InvalidReturnStatement

lib/Controller/AssistantApiController.php:464:11: InvalidReturnStatement: The inferred type 'OCP\AppFramework\Http\DataResponse<200, array{0: 401, error: 'User should be logged in'}, array<never, never>>' does not match the declared return type 'OCP\AppFramework\Http\DataResponse<200|401, array{error?: string, path?: string}, array<never, never>>' for OCA\Assistant\Controller\AssistantApiController::getAssistantFolderPath (see https://psalm.dev/128)

Check failure on line 464 in lib/Controller/AssistantApiController.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-master

InvalidReturnStatement

lib/Controller/AssistantApiController.php:464:11: InvalidReturnStatement: The inferred type 'OCP\AppFramework\Http\DataResponse<200, array{0: 401, error: 'User should be logged in'}, array<never, never>>' does not match the declared return type 'OCP\AppFramework\Http\DataResponse<200|401, array{error?: string, path?: string}, array<never, never>>' for OCA\Assistant\Controller\AssistantApiController::getAssistantFolderPath (see https://psalm.dev/128)
}

$folder = $this->assistantService->getAssistantDataFolder($this->userId);
return new DataResponse(['path' => $folder->getPath()]);
}
}
145 changes: 145 additions & 0 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -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: /<userId>/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",
Expand Down
Loading