Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.
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
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
"codewithkyrian/chromadb-php": "^0.2.1",
"mongodb/mongodb": "^1.20",
"php-cs-fixer/shim": "^3.70",
"phpstan/phpstan": "^1.12",
"phpstan/phpstan-webmozart-assert": "^1.2",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-webmozart-assert": "^2.0",
"phpunit/phpunit": "^11.5",
"probots-io/pinecone-php": "^1.0",
"rector/rector": "^1.2",
"rector/rector": "^2.0",
"symfony/console": "^6.4 || ^7.1",
"symfony/css-selector": "^6.4 || ^7.1",
"symfony/dom-crawler": "^6.4 || ^7.1",
Expand Down
1 change: 1 addition & 0 deletions phpstan.dist.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ parameters:
- examples/
- src/
- tests/
treatPhpDocTypesAsCertain: false
ignoreErrors:
-
message: '#no value type specified in iterable type array#'
Expand Down
2 changes: 2 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitSelfCallRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertCountWithZeroToAssertEmptyRector;
use Rector\PHPUnit\Set\PHPUnitSetList;

return RectorConfig::configure()
Expand All @@ -25,6 +26,7 @@
])
->withImportNames(importNames: true, importShortClasses: false)
->withSkip([
AssertCountWithZeroToAssertEmptyRector::class,
ClosureToArrowFunctionRector::class,
PreferPHPUnitThisCallRector::class,
])
Expand Down
47 changes: 22 additions & 25 deletions src/Bridge/Meta/LlamaPromptConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,42 +50,39 @@ public function convertMessage(UserMessage|SystemMessage|AssistantMessage $messa
ASSISTANT);
}

if ($message instanceof UserMessage) {
$count = count($message->content);

$contentParts = [];
if ($count > 1) {
foreach ($message->content as $value) {
if ($value instanceof Text) {
$contentParts[] = $value->text;
}

if ($value instanceof Image) {
$contentParts[] = $value->url;
}
}
} elseif (1 === $count) {
$value = $message->content[0];
// Handling of UserMessage
$count = count($message->content);

$contentParts = [];
if ($count > 1) {
foreach ($message->content as $value) {
if ($value instanceof Text) {
$contentParts[] = $value->text;
}

if ($value instanceof Image) {
$contentParts[] = $value->url;
}
} else {
throw new RuntimeException('Unsupported message type.');
}
} elseif (1 === $count) {
$value = $message->content[0];
if ($value instanceof Text) {
$contentParts[] = $value->text;
}

$content = implode(PHP_EOL, $contentParts);
if ($value instanceof Image) {
$contentParts[] = $value->url;
}
} else {
throw new RuntimeException('Unsupported message type.');
}

return trim(<<<USER
<|start_header_id|>{$message->getRole()->value}<|end_header_id|>
$content = implode(PHP_EOL, $contentParts);

{$content}<|eot_id|>
USER);
}
return trim(<<<USER
<|start_header_id|>{$message->getRole()->value}<|end_header_id|>

throw new RuntimeException('Unsupported message type.'); // @phpstan-ignore-line
{$content}<|eot_id|>
USER);
}
}
8 changes: 4 additions & 4 deletions src/Bridge/MongoDB/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ public function query(Vector $vector, array $options = [], ?float $minScore = nu
*/
public function initialize(array $options = []): void
{
try {
if ([] !== $options && !array_key_exists('fields', $options)) {
throw new InvalidArgumentException('The only supported option is "fields"');
}
if ([] !== $options && !array_key_exists('fields', $options)) {
throw new InvalidArgumentException('The only supported option is "fields"');
}

try {
$this->getCollection()->createSearchIndex(
[
'fields' => array_merge([
Expand Down
2 changes: 1 addition & 1 deletion src/Chain/ToolBox/Attribute/ToolParameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
final readonly class ToolParameter
{
/**
* @param string[]|null $enum
* @param list<int|string>|null $enum
* @param string|int|string[]|null $const
*/
public function __construct(
Expand Down
1 change: 0 additions & 1 deletion tests/Bridge/OpenAI/Embeddings/ResponseConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public function itConvertsAResponseToAVectorResponse(): void
$vectorResponse = (new ResponseConverter())->convert($response);
$convertedContent = $vectorResponse->getContent();

self::assertIsArray($convertedContent);
self::assertCount(2, $convertedContent);

self::assertSame([0.3, 0.4, 0.4], $convertedContent[0]->getData());
Expand Down