Skip to content

Commit

Permalink
fix issue
Browse files Browse the repository at this point in the history
  • Loading branch information
berkingurcan committed Jun 28, 2024
1 parent 6021559 commit 0132e10
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/tools/demoSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async function formatResults(matches: ScoredPineconeRecord[]) {
async function runTool(args: { query: string }): Promise<string> {
try {
const embeddings = await getEmbeddings(args.query)
const matches = await getMatchesFromEmbeddings(embeddings, 15, VECTOR_TYPE, undefined, true)
const matches = await getMatchesFromEmbeddings(embeddings, 15, VECTOR_TYPE)

return formatResults(matches)
} catch (e) {
Expand Down
15 changes: 5 additions & 10 deletions lib/tools/utils/pinecone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ const getMatchesFromEmbeddings = async (
embeddings: number[],
topK: number,
vector_type: string,
project_name?: string,
isDiscord?: boolean,
project_name?: string
): Promise<ScoredPineconeRecord<Metadata>[]> => {
const pinecone = new Pinecone({
environment: process.env.PINECONE_ENVIRONMENT as string,
Expand All @@ -46,15 +45,11 @@ const getMatchesFromEmbeddings = async (

const vectorType = getVectorType(vector_type)

const indexName: string = isDiscord
? 'discord-umstad'
: (process.env.PINECONE_INDEX || '');

if (!isDiscord && indexName === '') {
throw new Error('PINECONE_INDEX environment variable not set');
}
const indexName: string = process.env.PINECONE_INDEX || ''


if (indexName === '') {
throw new Error('PINECONE_INDEX environment variable not set')
}
const indexes = await pinecone.listIndexes()
if (indexes.filter(i => i.name === indexName).length !== 1) {
throw new Error(`Index ${indexName} does not exist`)
Expand Down

0 comments on commit 0132e10

Please sign in to comment.