-
Notifications
You must be signed in to change notification settings - Fork 70
Update ingest
for Azure
#2843
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
Merged
Merged
Update ingest
for Azure
#2843
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ae8f464
Add initial package.json for chatbot-server
TheSonOfThomp ae8aeac
feat(ui): initialize chatbot UI with React and Vite (#2841)
tsck 83131ec
feat(ui): initialize chatbot UI with React and Vite
tsck 0f2cc51
fix: update license to Apache-2.0 and refactor import statements for …
tsck 1ff0d08
feat(ingest): add initial configuration and data sources for chatbot …
TheSonOfThomp 3090e51
update configs
TheSonOfThomp f9886ae
feat(ingest): implement data sources for LeafyGreen UI and MongoDB Ch…
TheSonOfThomp e44b87e
chore: update pnpm workspace configuration to include 'apps/*' directory
TheSonOfThomp 2ea3036
feat(ingest): update ingest configuration to use Azure OpenAI and add…
TheSonOfThomp 780eeb5
feat(ingest): enhance environment variable loading and add MongoDB ch…
TheSonOfThomp 082f867
feat(ingest): add data sources for LeafyGreen UI and MongoDB Chatbot …
TheSonOfThomp 2573b34
feat(ingest): remove MongoDB connection URI from example environment …
TheSonOfThomp ff21777
feat: remove ts-node from devDependencies and update package versions…
TheSonOfThomp 0f8d46b
feat(ingest): add MongoDB Design website data source and integrate in…
TheSonOfThomp 2bfd1a6
Update pnpm-lock.yaml
TheSonOfThomp 7b13b13
Delete package-lock.json
TheSonOfThomp 353961a
reset ui
TheSonOfThomp 5c35c9c
Update .env.example
TheSonOfThomp 5099e15
rm wip web loader
TheSonOfThomp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
# MongoDB config | ||
MONGODB_CONNECTION_URI="<MongoDB connection URI with Atlas Vector Search configured on 'embedded_content'>" | ||
MONGODB_USER=<YOUR_MONGODB_USER> | ||
MONGODB_PASSWORD=<YOUR_MONGODB_PASSWORD> | ||
MONGODB_PROJECT_URL=<YOUR_PROJECT_URL> | ||
MONGODB_APP_NAME=LeafyGreenAI | ||
|
||
VECTOR_SEARCH_INDEX_NAME="vector_index" # or whatever your index name is | ||
MONGODB_DATABASE_NAME="mongodb-chatbot-framework-chatbot" # or whatever your database name is. must contain vector search index. | ||
|
||
# OpenAI config | ||
OPENAI_API_KEY=<OpenAI API key> | ||
OPENAI_EMBEDDING_MODEL="text-embedding-ada-002" # or other model | ||
OPENAI_CHAT_COMPLETION_MODEL="gpt-3.5-turbo" # or other model | ||
|
||
# Azure OpenAI config | ||
AZURE_API_KEY1=<YOUR_AZURE_API_KEY1> | ||
AZURE_API_KEY2=<YOUR_AZURE_API_KEY2> | ||
AZURE_OPENAI_ENDPOINT=https://<your-instance>.openai.azure.com/ | ||
AZURE_OPENAI_EMBEDDING_MODEL=text-embedding-ada-002 | ||
AZURE_OPENAI_CHAT_COMPLETION_MODEL=gpt-3.5-turbo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
.../src/mongodbChatbotFrameworkDataSource.ts → ...t/sources/github-mdb-chatbot-framework.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"extends": "@lg-tools/build/config/package.tsconfig.json", | ||
"compilerOptions": { | ||
"module": "NodeNext", | ||
"moduleResolution": "nodenext", | ||
"target": "ES2017", | ||
"rootDir": ".", | ||
"outDir": "../dist", | ||
"emitDeclarationOnly": false, | ||
"composite": false, | ||
"declaration": false, | ||
"declarationMap": false, | ||
"noEmit": false, | ||
}, | ||
"files": [ | ||
"./ingest.config.ts" | ||
], | ||
"include": ["./**/*.ts"], | ||
} |
35 changes: 35 additions & 0 deletions
35
apps/chatbot-server/ingest/utils/createAzureEmbedderConstructor.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { EmbedArgs, Embedder } from 'mongodb-rag-core'; | ||
import { AzureOpenAI } from 'mongodb-rag-core/openai'; | ||
import { Constructor } from 'mongodb-rag-ingest'; | ||
|
||
/** | ||
* Returns a constructor function for an embedder that uses Azure OpenAI | ||
* to create embeddings. | ||
* @returns | ||
*/ | ||
export const createAzureEmbedderConstructor = | ||
({ | ||
azureClient, | ||
model, | ||
}: { | ||
azureClient: AzureOpenAI; | ||
model: string; | ||
}): Constructor<Embedder> => | ||
() => { | ||
const embed: Embedder['embed'] = async (args: EmbedArgs) => { | ||
const result = await azureClient.embeddings.create({ | ||
input: args.text, | ||
model, | ||
}); | ||
|
||
return { | ||
// @ts-expect-error | ||
embedding: result.data as Array<number>, | ||
}; | ||
}; | ||
|
||
return { | ||
embed, | ||
modelName: model, | ||
}; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { strict as assert } from 'assert'; | ||
import dotenv from 'dotenv'; | ||
|
||
/** | ||
Load environment variables from a .env file at the given path. | ||
Note that if you change the environment variable names, | ||
you need to update this function to support those environment variables. | ||
*/ | ||
export function loadEnvVars() { | ||
dotenv.config(); | ||
const { | ||
MONGODB_USER, | ||
MONGODB_PASSWORD, | ||
MONGODB_PROJECT_URL, | ||
MONGODB_APP_NAME, | ||
MONGODB_DATABASE_NAME, | ||
VECTOR_SEARCH_INDEX_NAME, | ||
OPENAI_API_KEY, | ||
OPENAI_EMBEDDING_MODEL, | ||
} = process.env; | ||
const requiredEnvVars = { | ||
MONGODB_USER, | ||
MONGODB_PASSWORD, | ||
MONGODB_PROJECT_URL, | ||
MONGODB_APP_NAME, | ||
MONGODB_DATABASE_NAME, | ||
VECTOR_SEARCH_INDEX_NAME, | ||
OPENAI_API_KEY, | ||
OPENAI_EMBEDDING_MODEL, | ||
} as const; | ||
|
||
for (const [name, value] of Object.entries(requiredEnvVars)) { | ||
assert(value, `${name} is required`); | ||
} | ||
|
||
const MONGODB_CONNECTION_URI = `mongodb+srv://${MONGODB_USER}:${MONGODB_PASSWORD}@${MONGODB_PROJECT_URL}/?retryWrites=true&w=majority&appName=${MONGODB_APP_NAME}`; | ||
|
||
return { | ||
MONGODB_CONNECTION_URI, | ||
MONGODB_USER, | ||
MONGODB_PASSWORD, | ||
MONGODB_PROJECT_URL, | ||
MONGODB_APP_NAME, | ||
MONGODB_DATABASE_NAME, | ||
VECTOR_SEARCH_INDEX_NAME, | ||
OPENAI_API_KEY, | ||
OPENAI_EMBEDDING_MODEL, | ||
} as Record<string, string>; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Not sure if my TS server is just being funky but it's indicating that this directive isn't necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm still getting this after reinstalling and restarting the server