Skip to content

Commit

Permalink
Merge pull request #59 from UmstadAI/add-vector-types-for-bot
Browse files Browse the repository at this point in the history
Add vector types for bot
  • Loading branch information
berkingurcan authored Apr 18, 2024
2 parents 9025e9a + a42a067 commit a4f57d8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ DOCS_VECTOR_TYPE=XXXXX
CODE_VECTOR_TYPE=XXXXX
PROJECT_VECTOR_TYPE=XXXXX
ISSUE_VECTOR_TYPE=XXXXX
SEARCH_VECTOR_TYPE=XXXXX

# Generate a random secret: https://generate-secret.vercel.app/32 or `openssl rand -base64 32`
AUTH_SECRET=XXXXXXXX
Expand Down
2 changes: 1 addition & 1 deletion lib/tools/utils/embeddings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const openai = new OpenAI(config)
export async function getEmbeddings(input: string) {
try {
const response = await openai.embeddings.create({
model: 'text-embedding-ada-002',
model: 'text-embedding-3-small',
input: input.replace(/\n/g, ' ')
})

Expand Down
7 changes: 4 additions & 3 deletions lib/tools/utils/pinecone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type Metadata = {
hash: string
}

type VectorType = 'docs' | 'code' | 'project' | 'issue'
type VectorType = 'docs' | 'code' | 'project' | 'issue' | 'search'

function getVectorType(vector_type: string): string | undefined {
if (!isVectorType(vector_type)) {
Expand All @@ -20,14 +20,15 @@ function getVectorType(vector_type: string): string | undefined {
docs: process.env.DOCS_VECTOR_TYPE,
code: process.env.CODE_VECTOR_TYPE,
project: process.env.PROJECT_VECTOR_TYPE,
issue: process.env.ISSUE_VECTOR_TYPE
issue: process.env.ISSUE_VECTOR_TYPE,
search: process.env.SEARCH_VECTOR_TYPE
}

return vectorTypeMap[vector_type]
}

function isVectorType(type: string): type is VectorType {
return ['docs', 'code', 'project', 'issue'].includes(type)
return ['docs', 'code', 'project', 'issue', 'search'].includes(type)
}

const getMatchesFromEmbeddings = async (
Expand Down

0 comments on commit a4f57d8

Please sign in to comment.