Skip to content

Commit

Permalink
fix:lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhongpinWang committed Feb 14, 2025
1 parent be724dd commit aadb005
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
18 changes: 8 additions & 10 deletions packages/prompt-registry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ In addition, you can find more **sample code** [here](https://github.com/SAP/ai-
### List Prompt Templates

```ts
const response: PromptTemplateListResponse = await PromptTemplatesApi.listPromptTemplates(
{
const response: PromptTemplateListResponse =
await PromptTemplatesApi.listPromptTemplates({
scenario: 'test'
}
).execute();
}).execute();
```

### Custom Destination
Expand All @@ -55,13 +54,12 @@ When calling the `execute()` method, it is possible to provide a custom destinat
For example, when querying deployments targeting a destination with the name `my-destination`, the following code can be used:

```ts
const response: PromptTemplateListResponse = await PromptTemplatesApi.listPromptTemplates(
{
const response: PromptTemplateListResponse =
await PromptTemplatesApi.listPromptTemplates({
scenario: 'test'
}
).execute({
destinationName: 'my-destination'
});
}).execute({
destinationName: 'my-destination'
});
```

## Local Testing
Expand Down
14 changes: 11 additions & 3 deletions sample-code/src/prompt-registry.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { PromptTemplatesApi } from '@sap-ai-sdk/prompt-registry';
import type { PromptTemplateDeleteResponse, PromptTemplatePostResponse } from '@sap-ai-sdk/prompt-registry';
import type {
PromptTemplateDeleteResponse,
PromptTemplatePostResponse
} from '@sap-ai-sdk/prompt-registry';

/**
* Create a prompt template.
* @param name - The name of the prompt template.
* @param scenario - The scenario of the prompt template.
* @returns Prompt template post response.
*/
export async function createPromptTemplate(name: string, scenario: string): Promise<PromptTemplatePostResponse> {
export async function createPromptTemplate(
name: string,
scenario: string
): Promise<PromptTemplatePostResponse> {
return PromptTemplatesApi.createUpdatePromptTemplate({
name,
scenario,
Expand All @@ -28,6 +34,8 @@ export async function createPromptTemplate(name: string, scenario: string): Prom
* @param id - The id of the prompt template.
* @returns Prompt template delete response.
*/
export async function deletePromptTemplate(id: string): Promise<PromptTemplateDeleteResponse> {
export async function deletePromptTemplate(
id: string
): Promise<PromptTemplateDeleteResponse> {
return PromptTemplatesApi.deletePromptTemplate(id).execute();
}
12 changes: 8 additions & 4 deletions sample-code/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ import {
deleteCollection,
retrieveDocuments
} from './document-grounding.js';
import {
createPromptTemplate,
deletePromptTemplate
} from './prompt-registry.js';
import type { RetievalPerFilterSearchResult } from '@sap-ai-sdk/document-grounding';
import type { AiApiError, AiDeploymentStatus } from '@sap-ai-sdk/ai-api';
import type { OrchestrationResponse } from '@sap-ai-sdk/orchestration';
import { createPromptTemplate, deletePromptTemplate } from './prompt-registry.js';

const app = express();
const port = 8080;
Expand Down Expand Up @@ -563,11 +566,12 @@ app.get('/prompt-registry/invoke', async (req, res) => {
res.setHeader('Connection', 'keep-alive');
res.flushHeaders();

const { id } = await createPromptTemplate('ai-sdk-js-sample', 'orchestration');
const { id } = await createPromptTemplate(
'ai-sdk-js-sample',
'orchestration'
);
res.write(`Prompt template created: ${id}\n`);



const response = await deletePromptTemplate(id);
res.write(`Prompt template deleted: ${response.message}\n`);

Expand Down

0 comments on commit aadb005

Please sign in to comment.