-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from sitegeist/assistantsV2
Adjust to assistants v2
- Loading branch information
Showing
8 changed files
with
131 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sitegeist\Chatterbox\Domain\Knowledge; | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
use Sitegeist\Chatterbox\Domain\OrganizationDiscriminator; | ||
|
||
#[Flow\Proxy(false)] | ||
final readonly class VectorStoreName | ||
{ | ||
public function __construct( | ||
public KnowledgeSourceDiscriminator $knowledgeSourceDiscriminator, | ||
public int $timestamp, | ||
) { | ||
} | ||
|
||
public static function forKnowledgeSource(KnowledgeSourceDiscriminator $knowledgeSourceDiscriminator): self | ||
{ | ||
return new self( | ||
$knowledgeSourceDiscriminator, | ||
time() | ||
); | ||
} | ||
|
||
public static function tryFromNullableString(?string $value): ?self | ||
{ | ||
if ($value === null) { | ||
return null; | ||
} | ||
|
||
if (substr_count($value, '-') !== 2) { | ||
return null; | ||
} | ||
list($discriminator, $sourceName, $timestamp) = explode('-', $value); | ||
|
||
if (!is_numeric($timestamp)) { | ||
return null; | ||
} | ||
|
||
return new self( | ||
new KnowledgeSourceDiscriminator( | ||
new OrganizationDiscriminator($discriminator), | ||
new KnowledgeSourceName($sourceName) | ||
), | ||
(int)$timestamp | ||
); | ||
} | ||
|
||
public function takesPrecedenceOver(self $other): bool | ||
{ | ||
if ($this->knowledgeSourceDiscriminator->equals($other->knowledgeSourceDiscriminator) === false) { | ||
return false; | ||
} | ||
|
||
return $this->timestamp > $other->timestamp; | ||
} | ||
|
||
public function toString(): string | ||
{ | ||
return $this->knowledgeSourceDiscriminator->toString() . '-' . $this->timestamp; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters