You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For local testing instructions, refer to this [section](https://github.com/SAP/ai-sdk-js/blob/main/README.md#local-testing).
209
-
210
-
## Support, Feedback, Contribution
211
-
212
-
This project is open to feature requests, bug reports and questions via [GitHub issues](https://github.com/SAP/ai-sdk-js/issues).
213
-
214
-
Contribution and feedback are encouraged and always welcome.
215
-
For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](https://github.com/SAP/ai-sdk-js/blob/main/CONTRIBUTING.md).
216
-
217
-
## License
218
-
219
-
The SAP Cloud SDK for AI is released under the [Apache License Version 2.0.](http://www.apache.org/licenses/).
public destination?: HttpDestinationOrFetchOptions
76
69
77
-
In addition to the default parameters of the model vendor (e.g., OpenAI) and LangChain, additional parameters can be used to help narrow down the search for the desired model:
70
+
A minimal example to instantiate the orchestration client uses a template and model name:
78
71
79
72
```ts
80
-
const chatClient =newAzureOpenAiChatClient({
81
-
modelName: 'gpt-4o',
82
-
modelVersion: '24-07-2021',
83
-
resourceGroup: 'my-resource-group'
84
-
});
85
-
```
86
-
87
-
**Do not pass a `deployment ID` to initialize the client.**
88
-
For the LangChain model clients, initialization is done using the model name, model version and resource group.
89
-
90
-
An important note is that LangChain clients by default attempt 6 retries with exponential backoff in case of a failure.
91
-
Especially in testing environments you might want to reduce this number to speed up the process:
73
+
const config:OrchestrationModuleConfig= {
74
+
llm: {
75
+
model_name: 'gpt-35-turbo'
76
+
},
77
+
templating: {
78
+
template: [
79
+
{ role: 'user', content: 'Give me a long introduction of {{?subject}}' }
80
+
]
81
+
}
82
+
};
92
83
93
-
```ts
94
-
const embeddingClient =newOrchestrationClient({
95
-
modelName: 'gpt-4o',
96
-
maxRetries: 0
97
-
});
84
+
const client =newOrchestratioClient(config);
98
85
```
99
86
100
87
#### Custom Destination
101
88
102
-
When initializing the `AzureOpenAiChatClient` and `AzureOpenAiEmbeddingClient` clients, it is possible to provide a custom destination.
89
+
When initializing the `OrchestrationClient`, it is possible to provide a custom destination.
103
90
For example, when targeting a destination with the name `my-destination`, the following code can be used:
104
91
105
92
```ts
106
-
const chatClient =newAzureOpenAiChatClient(
107
-
{
108
-
modelName: 'gpt-4o',
109
-
modelVersion: '24-07-2021',
110
-
resourceGroup: 'my-resource-group'
111
-
},
93
+
const client =newOrchestrationClient(
94
+
orchestrationConfig,
95
+
langchainOptions,
96
+
deploymentConfig,
112
97
{
113
98
destinationName: 'my-destination'
114
99
}
@@ -118,54 +103,48 @@ const chatClient = new AzureOpenAiChatClient(
118
103
By default, the fetched destination is cached.
119
104
To disable caching, set the `useCache` parameter to `false` together with the `destinationName` parameter.
120
105
121
-
### Chat Client
106
+
### Client Invocation
122
107
123
-
The chat client allows you to interact with Azure OpenAI chat models, accessible via the generative AI hub of SAP AI Core.
124
-
To invoke the client, pass a prompt:
108
+
When invoking the client, you only have to pass a message history and most of the time input parameters for the template module.
125
109
126
110
```ts
127
-
const response =awaitchatClient.invoke("What's the capital of France?");
111
+
const systemMessage =newSystemMessage('Be a helpful assisstant!');
112
+
const history = [systemMessage];
113
+
const response =awaitclient.invoke(history, {
114
+
inputParams: { subject: 'paris' }
115
+
});
116
+
```
117
+
118
+
#### Resilience
119
+
120
+
If you need to add resilience to your client, you can make use of the default options available in LangChain, most importantly `timeout` and `maxRetry`.
121
+
122
+
##### Timeout
123
+
124
+
By default, there is no timeout set in the client, if you want to limit the maximum duration the entire request, including retries, should take,
125
+
you can set a timeout duration in ms when using the invoke method:
For local testing instructions, refer to this [section](https://github.com/SAP/ai-sdk-js/blob/main/README.md#local-testing).
161
144
162
-
## Support, Feedback, Contribution
163
-
164
-
This project is open to feature requests, bug reports and questions via [GitHub issues](https://github.com/SAP/ai-sdk-js/issues).
165
-
166
-
Contribution and feedback are encouraged and always welcome.
167
-
For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](https://github.com/SAP/ai-sdk-js/blob/main/CONTRIBUTING.md).
145
+
## Limitations
168
146
169
-
## License
147
+
Currently unsupported features are:
170
148
171
-
The SAP Cloud SDK for AI is released under the [Apache License Version 2.0.](http://www.apache.org/licenses/).
0 commit comments