You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just a little help. Is it possible to do that ? I tried different way to resolve this point: I do not understand why with a text file it works but with this process it does not work. At the end the embedding is the same ?
Thank you for your help.
$documents = 'I love food when I am in restaurant';
$embeddingGenerator = new OpenAI3LargeEmbeddingGenerator();
$documents = $embeddingGenerator->embedText($documents);
// Créer une instance de MemoryVectorStore et ajouter les documents
$memoryVectorStore = new MemoryVectorStore();
$memoryVectorStore->addDocuments($documents);
// Créer une instance de QuestionAnswering
$qa = new QuestionAnswering(
$memoryVectorStore,
$embeddingGenerator,
new OpenAIChat()
);
// Répondre à la question
$answer = $qa->answerQuestion('Where do you love food?');
echo $answer;
error
HP Warning: Attempt to read property "embedding" on float in /home/www/......./llphant/src/Embeddings/VectorStores/Memory/MemoryVectorStore.php on line 50
[12-May-2024 18:20:10 UTC] PHP Stack trace:
[12-May-2024 18:20:10 UTC] PHP 1. {main}() /home/www/toto_db.php:0
[12-May-2024 18:20:10 UTC] PHP 2. LLPhant\Query\SemanticSearch\QuestionAnswering->answerQuestion($question = 'Where do you love food?', $k = *uninitialized*, $additionalArguments = *uninitialized*) /home/www/toto_db.php:49
or
$documents = 'I love food when I am in restaurant';
$embeddingGenerator = new OpenAI3LargeEmbeddingGenerator();
$embeddedDocuments = $embeddingGenerator->embedText($documents);
$documents = [];
foreach ($embeddedDocuments as $embedding) {
$document = new Document();
$document->embedding = [$embedding];
$documents[] = $document;
}
$memoryVectorStore = new MemoryVectorStore();
$memoryVectorStore->addDocuments($documents);
$qa = new QuestionAnswering(
$memoryVectorStore,
$embeddingGenerator,
new OpenAIChat()
);
$answer = $qa->answerQuestion('Where you love food?');
echo $answer;
error
PHP Fatal error: Uncaught InvalidArgumentException: Arrays must have the same length. in /home/www/.......theodo-group/llphant/src/Embeddings/VectorStores/DistanceL2Utils.php:18
Stack trace:
#0 /home/www/...../theodo-group/llphant/src/Embeddings/VectorStores/Memory/MemoryVectorStore.php(53): LLPhant\Embeddings\VectorStores\DistanceL2Utils::euclideanDistanceL2()
#1 /home/www/......r/theodo-group/llphant/src/Query/SemanticSearch/QuestionAnswering.php(64): LLPhant\Embeddings\VectorStores\Memory\MemoryVectorStore->similaritySearch()
#2 /home/www......../theodo-group/llphant/src/Query/SemanticSearch/QuestionAnswering.php(25): LLPhant\Query\SemanticSearch\QuestionAnswering->searchDocumentAndCreateSystemMessage()
The text was updated successfully, but these errors were encountered:
@ClicShopping the MemoryVectorStore::addDocuments() needs an array of Document objects as parameter. You can also use the addDocument that require only a single Document object.
The correct solution is the second but you need to adjust the code as follows (the embedText returns the array of embeddings and not an array of docs):
$text = 'I love food when I am in restaurant';
$embeddingGenerator = newOpenAI3LargeEmbeddingGenerator();
$embedding = $embeddingGenerator->embedText($text);
$document = newDocument();
$document->content = $text;
$document->embedding = $embedding;
$memoryVectorStore = newMemoryVectorStore();
$memoryVectorStore->addDocument($document);
$qa = newQuestionAnswering(
$memoryVectorStore,
$embeddingGenerator,
newOpenAIChat()
);
$answer = $qa->answerQuestion('Where you love food?');
echo$answer;
Hello,
Just a little help. Is it possible to do that ? I tried different way to resolve this point: I do not understand why with a text file it works but with this process it does not work. At the end the embedding is the same ?
Thank you for your help.
error
or
error
The text was updated successfully, but these errors were encountered: