Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions tutorials/ai-core-consumption-LLM/ai-core-consumption-llm.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,28 @@ print(response.to_dict()["choices"][0]["message"]["content"])
```
[OPTION END]

[OPTION BEGIN [JavaScript SDK]]

In this example we will see how to consume this generative AI model using the SAP AI SDK for JavaScript.

Before we proceed, ensure that the `@sap-ai-sdk/foundation-models` package has been installed. Refer to the [SAP AI SDK for JavaScript](https://github.com/SAP/ai-sdk-js) for setup instructions.

Before you use these models, please ensure that the deployment has already been created. You can create the deployment either through generative-ai-hub-sdk or AI Launchpad.

```javascript
import { AzureOpenAiChatClient } from '@sap-ai-sdk/foundation-models';

const client = new AzureOpenAiChatClient('gpt-4o-mini');
const response = await client.run({
messages: [{ role: 'user', content: 'What is SAP Business AI?' }],
max_tokens: 100,
temperature: 0.0
});
console.log(response.getContent());
```

[OPTION END]

For more information on the models refer to [GPT4.0 Mini](https://openai.com/index/gpt-4o-mini-advancing-cost-efficient-intelligence/).

### LLAMA 3.1
Expand Down Expand Up @@ -397,6 +419,28 @@ print(response.data)

[OPTION END]

[OPTION BEGIN [JavaScript SDK]]

In this example we will see how to consume this generative AI model using the SAP AI SDK for JavaScript.

Before we proceed, ensure that the `@sap-ai-sdk/foundation-models` package has been installed. Refer to the [SAP AI SDK for JavaScript](https://github.com/SAP/ai-sdk-js) for setup instructions.

Before you use these models, please ensure that the deployment has already been created. You can create the deployment either through generative-ai-hub-sdk or AI Launchpad.

```javascript
import { AzureOpenAiEmbeddingClient } from '@sap-ai-sdk/foundation-models';

const client = new AzureOpenAiEmbeddingClient('text-embedding-3-small');
const response = await client.run({
input: 'Every decoding is another encoding.'
});
console.log(response.getEmbedding());
```

**NOTE** - you can switch the model name between `text-embedding-ada-002`, `text-embedding-3-small`, and `text-embedding-3-large` as per requirement.

[OPTION END]

For more information on the models refer to [Embeddings - OpenAI](https://platform.openai.com/docs/guides/embeddings/use-cases).

### Textembedding-gecko
Expand Down