Skip to content

Commit

Permalink
Merge pull request #12 from sitegeist/task/makeLoggingOptional
Browse files Browse the repository at this point in the history
TASK: Make logging optional and controll via setting in Develop this is still enabled
  • Loading branch information
mficzel authored Apr 3, 2024
2 parents 3dc806c + 223d724 commit f2b69a7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 17 deletions.
16 changes: 0 additions & 16 deletions Classes/Domain/Assistant.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ private function completeRun(string $threadId, string $runId): void
if ($toolInstance instanceof ToolContract) {
$toolResult = $toolInstance->execute(json_decode($requiredToolCall->function->arguments, true));
$toolOutputs["tool_outputs"][] = ['tool_call_id' => $requiredToolCall->id, 'output' => json_encode($toolResult->getData())];
$this->collectedMetadata = Arrays::arrayMergeRecursiveOverrule($this->collectedMetadata, ['tool_calls' => ['name' => $requiredToolCall->function->name, 'parameters' => $requiredToolCall->function->arguments]]);
$this->collectedMetadata = Arrays::arrayMergeRecursiveOverrule($this->collectedMetadata, $toolResult->getMetadata());
}
}
Expand All @@ -128,19 +127,4 @@ private function completeRun(string $threadId, string $runId): void
}
$this->logger?->info("thread run response", $threadRunResponse->toArray());
}

// // add tool metadata
// if ($combinedMetadata) {
// $stepList = $this->client->threads()->runs()->steps()->list($threadId, $threadRunResponse->id);
// foreach ($stepList->data as $stepResponse) {
// $stepDetails = $stepResponse->stepDetails;
// if ($stepDetails instanceof ThreadRunStepResponseMessageCreationStepDetails) {
// $messageId = $stepDetails->messageCreation->messageId;
// if ($messageId) {
// $this->client->threads()->messages()->modify($threadId, $messageId, ['metadata' => ['tools' => json_encode($combinedMetadata)]]);
// break;
// }
// }
// }
// }
}
15 changes: 14 additions & 1 deletion Classes/Domain/AssistantDepartment.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@

class AssistantDepartment
{
/**
* @var array<string, mixed>
*/
private array $settings = [];

public function __construct(
private readonly OpenAiClientContract $client,
private readonly DatabaseConnection $connection,
Expand All @@ -33,6 +38,14 @@ public function __construct(
) {
}

/**
* @param array<string, mixed> $settings
*/
public function injectSettings(array $settings): void
{
$this->settings = $settings;
}

public function findAssistantById(string $assistantId): Assistant
{
$assistantRecord = $this->findAssistantRecordById($assistantId);
Expand Down Expand Up @@ -60,7 +73,7 @@ public function findAssistantById(string $assistantId): Assistant
$this->organizationDiscriminator,
$this->client,
$this->connection,
$this->logger
($this->settings['enableLogging'] ?? false) ? $this->logger : null
);
}

Expand Down
3 changes: 3 additions & 0 deletions Configuration/Development/Settings.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Sitegeist:
Chatterbox:
enableLogging: true
1 change: 1 addition & 0 deletions Configuration/Settings.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Sitegeist:
Chatterbox:
enableLogging: false
organizations: []
# orgId:
# discriminator: 'my-descriminator'
Expand Down

0 comments on commit f2b69a7

Please sign in to comment.