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

[spruce] Bump @pinecone-database version to support global control plane #29

Open
wants to merge 2 commits into
base: spruce
Choose a base branch
from
Open
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
3 changes: 1 addition & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ OPENAI_API_KEY=

# Retrieve the following from the Pinecone Console.

# Navigate to API Keys under your Project to retrieve the API key and environment
# Navigate to API Keys under your Project to retrieve the API key
PINECONE_API_KEY=
PINECONE_ENVIRONMENT=
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why we're removing this?


# Navigate to Indexes under your Project to retrieve the Index name
PINECONE_INDEX=
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"@pinecone-database/doc-splitter": "^0.0.1",
"@pinecone-database/pinecone": "^1.1.0",
"@pinecone-database/pinecone": "^1.1.2-spruceDev.20231214000822",
"@types/node": "20.4.0",
"@types/react": "18.2.14",
"@types/react-dom": "18.2.6",
Expand Down
8 changes: 7 additions & 1 deletion src/app/api/crawl/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,17 @@ async function seed(url: string, limit: number, indexName: string, options: Seed

// Create Pinecone index if it does not exist
const indexList = await pinecone.listIndexes();
const indexExists = indexList.some(index => index.name === indexName)
const indexExists = indexList.indexes?.some(index => index.name === indexName)
if (!indexExists) {
await pinecone.createIndex({
name: indexName,
dimension: 1536,
spec: {
serverless: {
region: 'us-west-2',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this shouldn't be hard coded, but set in .env

cloud: 'aws',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

}
},
waitUntilReady: true,
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/utils/embeddings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function getEmbeddings(input: string) {
model: "text-embedding-ada-002",
input: input.replace(/\n/g, ' ')
})

const result = await response.json();
return result.data[0].embedding as number[]

Expand Down
4 changes: 2 additions & 2 deletions src/app/utils/pinecone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const getMatchesFromEmbeddings = async (embeddings: number[], topK: number, name
}

// Retrieve the list of indexes to check if expected index exists
const indexes = await pinecone.listIndexes()
if (indexes.filter(i => i.name === indexName).length !== 1) {
const indexList = await pinecone.listIndexes()
if (indexList.indexes?.filter(i => i.name === indexName).length !== 1) {
throw new Error(`Index ${indexName} does not exist`)
}

Expand Down