Skip to content

Commit

Permalink
Merge pull request #10 from sitegeist/task/updateInstructionsForEveryRun
Browse files Browse the repository at this point in the history
TASK: Ensure that instructions are updated for every run
  • Loading branch information
mficzel authored Mar 7, 2024
2 parents 06f4508 + 9496e48 commit 60c967d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Classes/Controller/AssistantModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function addThreadMessageAction(string $organizationId, string $threadId,
$organization = $this->organizationRepository->findById($organizationId);
$assistant = $organization->assistantDepartment->findAssistantById($assistantId);
try {
$assistant->continueThread($threadId, $message, $withAdditionalInstructions);
$assistant->continueThread($threadId, $message);
$metadata = $assistant->getCollectedMetadata();
$this->view->assignMultiple([
'organizationId' => $organizationId,
Expand Down
2 changes: 1 addition & 1 deletion Classes/Controller/ChatController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function startAction(string $organizationId, string $assistantId, string
$organization = $this->organizationRepository->findById($organizationId);
$assistant = $organization->assistantDepartment->findAssistantById($assistantId);
$threadId = $assistant->startThread();
$assistant->continueThread($threadId, $message, true);
$assistant->continueThread($threadId, $message);

$messageResponses = $assistant->readThread($threadId);
$lastMessageKey = array_key_last($messageResponses);
Expand Down
6 changes: 2 additions & 4 deletions Classes/Domain/Assistant.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function startThread(): string
return $threadResponse->id;
}

public function continueThread(string $threadId, string $message, bool $withAdditionalInstructions = false): void
public function continueThread(string $threadId, string $message): void
{
$this->client->threads()->messages()->create(
$threadId,
Expand All @@ -65,9 +65,7 @@ public function continueThread(string $threadId, string $message, bool $withAddi
$threadId,
array_filter([
'assistant_id' => $this->id,
'additional_instructions' => $withAdditionalInstructions
? $this->instructions->getContent()
: null
'additional_instructions' => $this->instructions->getContent()
])
);
$this->completeRun($threadId, $runResponse->id);
Expand Down

0 comments on commit 60c967d

Please sign in to comment.