Skip to content

Commit

Permalink
chore(generative-ai): add url endpoints for compass web usage COMPASS…
Browse files Browse the repository at this point in the history
  • Loading branch information
Anemy authored Nov 4, 2024
1 parent 6c4d534 commit 8b88964
Show file tree
Hide file tree
Showing 10 changed files with 488 additions and 316 deletions.
4 changes: 4 additions & 0 deletions package-lock.json

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

8 changes: 2 additions & 6 deletions packages/atlas-service/src/atlas-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@ export class AtlasService {
) {
this.config = getAtlasConfig(preferences);
}
adminApiEndpoint(path?: string, requestId?: string): string {
const uri = `${this.config.atlasApiBaseUrl}${normalizePath(path)}`;
const query = requestId
? `?request_id=${encodeURIComponent(requestId)}`
: '';
return `${uri}${query}`;
adminApiEndpoint(path?: string): string {
return `${this.config.atlasApiBaseUrl}${normalizePath(path)}`;
}
cloudEndpoint(path?: string): string {
return `${this.config.cloudBaseUrl}${normalizePath(path)}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,20 +281,23 @@ export const runAIPipelineGeneration = (

const { collection: collectionName, database: databaseName } =
toNS(namespace);
jsonResponse = await atlasAiService.getAggregationFromUserInput({
signal: abortController.signal,
userInput,
collectionName,
databaseName,
schema,
// Provide sample documents when the user has opted in in their settings.
...(provideSampleDocuments
? {
sampleDocuments,
}
: undefined),
requestId,
});
jsonResponse = await atlasAiService.getAggregationFromUserInput(
{
signal: abortController.signal,
userInput,
collectionName,
databaseName,
schema,
// Provide sample documents when the user has opted in in their settings.
...(provideSampleDocuments
? {
sampleDocuments,
}
: undefined),
requestId,
},
connectionInfo
);
} catch (err: any) {
if (signal.aborted) {
// If we already aborted so we ignore the error.
Expand Down
2 changes: 2 additions & 0 deletions packages/compass-generative-ai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"dependencies": {
"@mongodb-js/atlas-service": "^0.31.0",
"@mongodb-js/compass-components": "^1.31.0",
"@mongodb-js/compass-connections": "^1.45.0",
"@mongodb-js/compass-intercom": "^0.13.2",
"@mongodb-js/compass-logging": "^1.4.9",
"bson": "^6.8.0",
Expand All @@ -64,6 +65,7 @@
"react": "^17.0.2"
},
"devDependencies": {
"@mongodb-js/connection-info": "^0.9.2",
"@mongodb-js/eslint-config-compass": "^1.1.7",
"@mongodb-js/mocha-config-compass": "^1.4.2",
"@mongodb-js/prettier-config-compass": "^1.0.2",
Expand Down
Loading

0 comments on commit 8b88964

Please sign in to comment.