Skip to content

Commit

Permalink
Initial (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
newtork authored Jan 14, 2025
1 parent 97bc3b5 commit 31ec0cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
8 changes: 4 additions & 4 deletions docs/guides/AI_CORE_DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ Use the following code snippet to create a deployment in SAP AI Core:
```java
var api = new DeploymentApi();
var resourceGroupId = "default";
var configurationId = "12345-123-123-123-123456abcdefg";

AiDeploymentCreationRequest request =
AiDeploymentCreationRequest.create().configurationId("12345-123-123-123-123456abcdefg");
AiDeploymentCreationResponse deployment = api.create(resourceGroupId, request);
var request = AiDeploymentCreationRequest.create().configurationId(configurationId);
var deployment = api.create(resourceGroupId, request);

var id = deployment.getId();
String id = deployment.getId();
AiExecutionStatus status = deployment.getStatus();
```

Expand Down
13 changes: 6 additions & 7 deletions docs/guides/OPENAI_CHAT_COMPLETION.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ In addition to the prerequisites above, we assume you have already set up the fo
### Simple chat completion

```java
OpenAiChatCompletionOutput result =
var result =
OpenAiClient.forModel(GPT_35_TURBO)
.withSystemPrompt("You are a helpful AI")
.chatCompletion("Hello World! Why is this phrase so famous?");
Expand All @@ -117,8 +117,7 @@ var userMessage =
var request =
new OpenAiChatCompletionParameters().addMessages(systemMessage, userMessage);

OpenAiChatCompletionOutput result =
OpenAiClient.forModel(GPT_35_TURBO).chatCompletion(request);
var result = OpenAiClient.forModel(GPT_35_TURBO).chatCompletion(request);

String resultMessage = result.getContent();
```
Expand Down Expand Up @@ -177,12 +176,12 @@ Any asynchronous library can be used, such as the classic Thread API.
```java
var message = "Can you give me the first 100 numbers of the Fibonacci sequence?";

OpenAiChatMessage.OpenAiChatUserMessage userMessage =
var userMessage =
new OpenAiChatMessage.OpenAiChatUserMessage().addText(message);
OpenAiChatCompletionParameters requestParameters =
var requestParameters =
new OpenAiChatCompletionParameters().addMessages(userMessage);

OpenAiClient client = OpenAiClient.forModel(GPT_35_TURBO);
var client = OpenAiClient.forModel(GPT_35_TURBO);
var totalOutput = new OpenAiChatCompletionOutput();

// Prepare the stream before starting the thread to handle any initialization exceptions
Expand Down Expand Up @@ -216,7 +215,7 @@ Boot's `ResponseBodyEmitter` to stream the chat completion delta messages to the
Get the embeddings of a text input in list of float values:

```java
OpenAiEmbeddingParameters request = new OpenAiEmbeddingParameters().setInput("Hello World");
var request = new OpenAiEmbeddingParameters().setInput("Hello World");

OpenAiEmbeddingOutput embedding = OpenAiClient.forModel(TEXT_EMBEDDING_ADA_002).embedding(request);
```
Expand Down

0 comments on commit 31ec0cd

Please sign in to comment.