Skip to content
Merged
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
5 changes: 3 additions & 2 deletions lib/Controller/AssignmentsApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function __construct(

/**
* Create a new assignment
* @param string $title The title of the new assignment
* @param string $prompt The prompt to be sent to the assistant when the assignment is executed
* @param int $startsAt The timestamp when the assignment should start being executed
* @param string $recurrence The recurrence rule for the assignment, in RRULE format (e.g. "FREQ=DAILY;INTERVAL=1" for a daily assignment)
Expand All @@ -57,9 +58,9 @@ public function __construct(
#[NoAdminRequired]
#[OpenAPI(scope: OpenAPI::SCOPE_DEFAULT, tags: ['assignments'])]
#[Http\Attribute\ApiRoute(verb: 'POST', url: '/assignments')]
public function createUserAssignment(string $prompt, int $startsAt, string $recurrence): DataResponse {
public function createUserAssignment(string $title, string $prompt, int $startsAt, string $recurrence): DataResponse {
try {
$assignment = $this->assignmentsService->createAssignment($this->userId, $prompt, $startsAt, $recurrence);
$assignment = $this->assignmentsService->createAssignment($this->userId, $title, $prompt, $startsAt, $recurrence);
$serializedAssignment = $assignment->jsonSerialize();
return new DataResponse(['assignment' => $serializedAssignment]);
} catch (InternalException $e) {
Expand Down
4 changes: 2 additions & 2 deletions lib/Service/AssignmentsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(
* @throws UnauthorizedException
* @throws BadRequestException
*/
public function createAssignment(?string $userId, string $prompt, int $startsAt, string $recurrence): Assignment {
public function createAssignment(?string $userId, string $title, string $prompt, int $startsAt, string $recurrence): Assignment {
if ($userId === null) {
throw new UnauthorizedException();
}
Expand All @@ -61,7 +61,7 @@ public function createAssignment(?string $userId, string $prompt, int $startsAt,
} catch (Exception $e) {
throw new InternalException(previous: $e);
}
$session = $this->chatService->createChatSession($userId, $this->timeFactory->now()->getTimestamp(), 'Assignment ' . $assignment->getId()); // TODO: Add a proper title here
$session = $this->chatService->createChatSession($userId, $this->timeFactory->now()->getTimestamp(), $title);
$session->setAssignmentId($assignment->getId());
try {
$this->sessionMapper->update($session);
Expand Down
5 changes: 5 additions & 0 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -5334,11 +5334,16 @@
"schema": {
"type": "object",
"required": [
"title",
"prompt",
"startsAt",
"recurrence"
],
"properties": {
"title": {
"type": "string",
"description": "The title of the new assignment"
},
"prompt": {
"type": "string",
"description": "The prompt to be sent to the assistant when the assignment is executed"
Expand Down
Loading