Skip to content

Commit

Permalink
add discord index name for discord query
Browse files Browse the repository at this point in the history
  • Loading branch information
berkingurcan committed Jun 28, 2024
1 parent b2237e6 commit 4e80d3f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 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)
const matches = await getMatchesFromEmbeddings(embeddings, 15, VECTOR_TYPE, true)

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

const vectorType = getVectorType(vector_type)

const indexName: string = process.env.PINECONE_INDEX || ''
if (indexName === '') {
throw new Error('PINECONE_INDEX environment variable not set')
const indexName: string = isDiscord
? 'discord-umstad'
: (process.env.PINECONE_INDEX || '');

if (!isDiscord && indexName === '') {
throw new Error('PINECONE_INDEX environment variable not set');
}


const indexes = await pinecone.listIndexes()
if (indexes.filter(i => i.name === indexName).length !== 1) {
Expand Down

0 comments on commit 4e80d3f

Please sign in to comment.