diff --git a/packages/rage/src/index.ts b/packages/rage/src/index.ts index 93b88175..2e97c3da 100644 --- a/packages/rage/src/index.ts +++ b/packages/rage/src/index.ts @@ -1,3 +1,14 @@ export * from './client/pipeline/pipeline-api/index.js'; -export * as VectorApi from './client/vector/vector-api/index.js'; -export * as RetrievalApi from './client/retrieval/retrieval-api/index.js'; +export { + CollectionsApi, + DocumentsApi, + SearchApi, + SearchResults as VectorSearchResults, + Collection, + DocumentsListResponse +} from './client/vector/vector-api/index.js'; +export { + RetrievalFederatedSearchAcrossDataRepositoriesApi, + RetrievalDataRepositoryApi, + SearchResults as RetrievalSearchResults +} from './client/retrieval/retrieval-api/index.js'; diff --git a/sample-code/src/rage/retrieval-api.ts b/sample-code/src/rage/retrieval-api.ts index 00af5928..1e3b0d2c 100644 --- a/sample-code/src/rage/retrieval-api.ts +++ b/sample-code/src/rage/retrieval-api.ts @@ -1,4 +1,5 @@ -import { RetrievalApi } from '@sap-ai-sdk/rage'; +import { RetrievalFederatedSearchAcrossDataRepositoriesApi } from '@sap-ai-sdk/rage'; +import type { RetrievalSearchResults } from '@sap-ai-sdk/rage'; /** * Search for documents in a collection. @@ -11,8 +12,8 @@ export async function searchCollection( collectionId: string, query: string, resourceGroup: string -): Promise { - return RetrievalApi.RetrievalFederatedSearchAcrossDataRepositoriesApi.retrievalV1RetrievalEndpointsSearchDataRepositories( +): Promise { + return RetrievalFederatedSearchAcrossDataRepositoriesApi.retrievalV1RetrievalEndpointsSearchDataRepositories( { query, filters: [ diff --git a/sample-code/src/rage/vector-api.ts b/sample-code/src/rage/vector-api.ts index e01cbfcb..68c6cb80 100644 --- a/sample-code/src/rage/vector-api.ts +++ b/sample-code/src/rage/vector-api.ts @@ -1,4 +1,5 @@ -import { VectorApi } from '@sap-ai-sdk/rage'; +import { CollectionsApi, DocumentsApi } from '@sap-ai-sdk/rage'; +import type { Collection, DocumentsListResponse } from '@sap-ai-sdk/rage'; import type { HttpResponse } from '@sap-cloud-sdk/http-client'; /** * Create a new collection. @@ -11,7 +12,7 @@ export async function createCollection( resourceGroup: string ): Promise { const response: HttpResponse = - await VectorApi.CollectionsApi.vectorV1VectorEndpointsCreateCollection( + await CollectionsApi.vectorV1VectorEndpointsCreateCollection( { title, embeddingConfig: {}, @@ -43,11 +44,10 @@ export async function deleteCollection( collectionId: string, resourceGroup: string ): Promise { - const response = - await VectorApi.CollectionsApi.vectorV1VectorEndpointsDeleteCollection( - collectionId, - { 'AI-Resource-Group': resourceGroup } - ).execute(); + const response = await CollectionsApi.vectorV1VectorEndpointsDeleteCollection( + collectionId, + { 'AI-Resource-Group': resourceGroup } + ).execute(); return response; } @@ -60,11 +60,10 @@ export async function deleteCollection( export async function getCollection( collectionId: string, resourceGroup: string -): Promise { - return VectorApi.CollectionsApi.vectorV1VectorEndpointsGetCollectionById( - collectionId, - { 'AI-Resource-Group': resourceGroup } - ).execute(); +): Promise { + return CollectionsApi.vectorV1VectorEndpointsGetCollectionById(collectionId, { + 'AI-Resource-Group': resourceGroup + }).execute(); } /** @@ -78,8 +77,8 @@ export async function createDocument( collectionId: string, resourceGroup: string, content: string -): Promise { - return VectorApi.DocumentsApi.vectorV1VectorEndpointsCreateDocuments( +): Promise { + return DocumentsApi.vectorV1VectorEndpointsCreateDocuments( collectionId, { documents: [ diff --git a/tests/e2e-tests/src/vector-retrieval-api.test.ts b/tests/e2e-tests/src/vector-retrieval-api.test.ts index fa7ce49a..9b9a3efe 100644 --- a/tests/e2e-tests/src/vector-retrieval-api.test.ts +++ b/tests/e2e-tests/src/vector-retrieval-api.test.ts @@ -6,7 +6,7 @@ import { deleteCollection } from '@sap-ai-sdk/sample-code'; import { loadEnv } from './utils/load-env.js'; -import type { RetrievalApi, VectorApi } from '@sap-ai-sdk/rage'; +import type { Collection, RetrievalSearchResults } from '@sap-ai-sdk/rage'; loadEnv(); @@ -28,7 +28,7 @@ describe('VectorApi and RetrievalApi', () => { documentContent ); expect(document).toBeDefined(); - const searchResults: RetrievalApi.SearchResults = await searchCollection( + const searchResults: RetrievalSearchResults = await searchCollection( collectionId, 'what is joule?', 'default' @@ -46,10 +46,7 @@ describe('VectorApi and RetrievalApi', () => { }); afterAll(async () => { - const collection: VectorApi.Collection = await getCollection( - collectionId, - 'default' - ); + const collection: Collection = await getCollection(collectionId, 'default'); expect(collection).toBeDefined(); const response = await deleteCollection(collection.id, 'default'); expect(response).toBeDefined();