Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad Request (400) Response: {"code":3,"message":"Vector dimension 0 does not match the dimension of the index 1536","details":[]} #15

Open
omitpavel opened this issue Nov 21, 2024 · 0 comments

Comments

@omitpavel
Copy link

$embedding =$this->getEmbedding($chunk);
if (count($embedding) == 1536) {
$embedding = array_map('floatval', $embedding);
$this->pinecone->data()->vectors()->upsert([
'namespace' => $fileName, // Use namespace to group by file
'vectors' => [
[
'id' => "{$fileName}chunk{$index}",
'values' => array_values($embedding),
'metadata' => [
'source' => $fileName,
'chunk_index' => $index,
'upload_date' => now()->toDateString(),
'text' => substr($chunk, 0, 50) . '...', // Chunk preview
],
],
],
]);
}

            return Bad Request (400) Response: {"code":3,"message":"Vector dimension 0 does not match the dimension of the index 1536","details":[]}
            
            
            
            my get getEmbedding is
            
            private function getEmbedding(string $text): array
{
    $response = OpenAI::embeddings()->create([
        'model' => 'text-embedding-ada-002',
        'input' => $text,
    ]);

    return $response['data'][0]['embedding'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant