Skip to content

Commit

Permalink
chore: potentially fix public api checks
Browse files Browse the repository at this point in the history
  • Loading branch information
KavithaSiva committed Nov 28, 2024
1 parent c95f29a commit b6d08bf
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 25 deletions.
15 changes: 13 additions & 2 deletions packages/rage/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
7 changes: 4 additions & 3 deletions sample-code/src/rage/retrieval-api.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -11,8 +12,8 @@ export async function searchCollection(
collectionId: string,
query: string,
resourceGroup: string
): Promise<RetrievalApi.SearchResults> {
return RetrievalApi.RetrievalFederatedSearchAcrossDataRepositoriesApi.retrievalV1RetrievalEndpointsSearchDataRepositories(
): Promise<RetrievalSearchResults> {
return RetrievalFederatedSearchAcrossDataRepositoriesApi.retrievalV1RetrievalEndpointsSearchDataRepositories(
{
query,
filters: [
Expand Down
27 changes: 13 additions & 14 deletions sample-code/src/rage/vector-api.ts
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -11,7 +12,7 @@ export async function createCollection(
resourceGroup: string
): Promise<any> {
const response: HttpResponse =
await VectorApi.CollectionsApi.vectorV1VectorEndpointsCreateCollection(
await CollectionsApi.vectorV1VectorEndpointsCreateCollection(
{
title,
embeddingConfig: {},
Expand Down Expand Up @@ -43,11 +44,10 @@ export async function deleteCollection(
collectionId: string,
resourceGroup: string
): Promise<any> {
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;
}

Expand All @@ -60,11 +60,10 @@ export async function deleteCollection(
export async function getCollection(
collectionId: string,
resourceGroup: string
): Promise<VectorApi.Collection> {
return VectorApi.CollectionsApi.vectorV1VectorEndpointsGetCollectionById(
collectionId,
{ 'AI-Resource-Group': resourceGroup }
).execute();
): Promise<Collection> {
return CollectionsApi.vectorV1VectorEndpointsGetCollectionById(collectionId, {
'AI-Resource-Group': resourceGroup
}).execute();
}

/**
Expand All @@ -78,8 +77,8 @@ export async function createDocument(
collectionId: string,
resourceGroup: string,
content: string
): Promise<VectorApi.DocumentsListResponse> {
return VectorApi.DocumentsApi.vectorV1VectorEndpointsCreateDocuments(
): Promise<DocumentsListResponse> {
return DocumentsApi.vectorV1VectorEndpointsCreateDocuments(
collectionId,
{
documents: [
Expand Down
9 changes: 3 additions & 6 deletions tests/e2e-tests/src/vector-retrieval-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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'
Expand All @@ -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();
Expand Down

0 comments on commit b6d08bf

Please sign in to comment.