Skip to content

Commit 6d666c8

Browse files
Update dependency @sap-ai-sdk/orchestration to v2 (#56)
* Update dependency @sap-ai-sdk/orchestration to v2 * Refactor orchestration client usage in chatCompletion functions --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Daniel Richter <[email protected]>
1 parent 4d35f15 commit 6d666c8

File tree

6 files changed

+71
-111
lines changed

6 files changed

+71
-111
lines changed

pr-review/package-lock.json

Lines changed: 13 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pr-review/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"@octokit/plugin-throttling": "8.2.0",
2222
"@octokit/webhooks": "13.9.1",
2323
"@sap-ai-sdk/ai-api": "2.1.0",
24-
"@sap-ai-sdk/orchestration": "1.18.0",
24+
"@sap-ai-sdk/orchestration": "2.1.0",
2525
"axios": "1.13.1",
2626
"minimatch": "10.1.1",
2727
"mollitia": "0.2.0",

pr-review/src/ai-core-client.ts

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as core from "@actions/core"
2-
import { ChatMessage, OrchestrationClient, TokenUsage } from "@sap-ai-sdk/orchestration"
2+
import { ChatMessage, OrchestrationClient } from "@sap-ai-sdk/orchestration"
33
import { isAxiosError } from "axios"
44
import { inspect } from "node:util"
55
import { z } from "zod"
@@ -30,22 +30,24 @@ export async function chatCompletion(messages: ChatMessage[]): Promise<string> {
3030
core.info("Use the OrchestrationClient to call the model")
3131
const orchestrationClient = new OrchestrationClient(
3232
{
33-
llm: {
34-
model_name: config.model,
35-
model_params: config.modelParameters,
36-
model_version: config.modelVersion,
37-
},
38-
templating: {
39-
template: messages,
33+
promptTemplating: {
34+
model: {
35+
name: config.model,
36+
params: config.modelParameters,
37+
version: config.modelVersion,
38+
},
39+
prompt: {
40+
template: messages,
41+
},
4042
},
4143
},
4244
config.deploymentConfig,
4345
)
4446
const completion = await orchestrationClient.chatCompletion()
45-
core.info(inspect(completion.data, { depth: undefined, colors: true }))
47+
core.info(inspect(completion._data, { depth: undefined, colors: true }))
4648

47-
modelName = (completion.data?.module_results?.llm?.model_name as string) ?? modelName
48-
const tokenUsage: TokenUsage = completion.getTokenUsage()
49+
modelName = completion._data.final_result.model ?? modelName
50+
const tokenUsage = completion.getTokenUsage()
4951
promptTokens += tokenUsage.prompt_tokens
5052
completionTokens += tokenUsage.completion_tokens
5153

@@ -68,27 +70,29 @@ export async function chatCompletionWithJsonSchema<T extends z.ZodTypeAny>(zodSc
6870
try {
6971
core.info("Use the OrchestrationClient to call the model")
7072
const orchestrationClient = new OrchestrationClient({
71-
llm: {
72-
model_name: config.model,
73-
model_params: config.modelParameters,
74-
model_version: config.modelVersion,
75-
},
76-
templating: {
77-
template: [
78-
...messages,
79-
{
80-
role: "user",
81-
content: `Always return a plain JSON document with the following schema:\n\n ${JSON.stringify(jsonSchema, undefined, 2)} `,
82-
},
83-
],
73+
promptTemplating: {
74+
model: {
75+
name: config.model,
76+
params: config.modelParameters,
77+
version: config.modelVersion,
78+
},
79+
prompt: {
80+
template: [
81+
...messages,
82+
{
83+
role: "user",
84+
content: `Always return a plain JSON document with the following schema:\n\n ${JSON.stringify(jsonSchema, undefined, 2)} `,
85+
},
86+
],
87+
},
8488
},
8589
})
8690
const completion = await orchestrationClient.chatCompletion()
8791
core.info(inspect(completion.rawResponse.data, { depth: undefined, colors: true }))
8892
responseJson = `${completion.getContent()}`
8993

90-
modelName = (completion.data?.module_results?.llm?.model_name as string) ?? modelName
91-
const tokenUsage: TokenUsage = completion.getTokenUsage()
94+
modelName = completion._data.final_result.model ?? modelName
95+
const tokenUsage = completion.getTokenUsage()
9296
promptTokens += tokenUsage.prompt_tokens
9397
completionTokens += tokenUsage.completion_tokens
9498
} catch (error) {

pr-summary/package-lock.json

Lines changed: 13 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pr-summary/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@octokit/plugin-throttling": "8.2.0",
2121
"@octokit/webhooks": "13.9.1",
2222
"@sap-ai-sdk/ai-api": "2.1.0",
23-
"@sap-ai-sdk/orchestration": "1.18.0",
23+
"@sap-ai-sdk/orchestration": "2.1.0",
2424
"axios": "1.13.1",
2525
"minimatch": "10.1.1",
2626
"mollitia": "0.2.0",

pr-summary/src/ai-core-client.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as core from "@actions/core"
2-
import { ChatMessage, OrchestrationClient, TokenUsage } from "@sap-ai-sdk/orchestration"
2+
import { ChatMessage, OrchestrationClient } from "@sap-ai-sdk/orchestration"
33
import { isAxiosError } from "axios"
44
import { inspect } from "node:util"
55
import { config } from "./config.js"
@@ -26,22 +26,24 @@ export async function chatCompletion(messages: ChatMessage[]): Promise<string> {
2626
core.info("Call OrchestrationClient")
2727
const orchestrationClient = new OrchestrationClient(
2828
{
29-
llm: {
30-
model_name: config.model,
31-
model_params: config.modelParameters,
32-
model_version: config.modelVersion,
33-
},
34-
templating: {
35-
template: messages,
29+
promptTemplating: {
30+
model: {
31+
name: config.model,
32+
params: config.modelParameters,
33+
version: config.modelVersion,
34+
},
35+
prompt: {
36+
template: messages,
37+
},
3638
},
3739
},
3840
config.deploymentConfig,
3941
)
4042
const completion = await orchestrationClient.chatCompletion()
41-
core.info(inspect(completion.data, { depth: undefined, colors: true }))
43+
core.info(inspect(completion._data, { depth: undefined, colors: true }))
4244

43-
modelName = (completion.data?.module_results?.llm?.model_name as string) ?? modelName
44-
const tokenUsage: TokenUsage = completion.getTokenUsage()
45+
modelName = completion._data.final_result.model ?? modelName
46+
const tokenUsage = completion.getTokenUsage()
4547
promptTokens += tokenUsage.prompt_tokens
4648
completionTokens += tokenUsage.completion_tokens
4749

0 commit comments

Comments
 (0)