Commit 79d4eed
fix for wrong OpenAIClientOptions used with keyed OpenAIClient(s) (#11003)
* fix for wrong OpenAIClientOptions used with keyed OpenAIClient(s)
with keyed OpenAIClients
```
builder.AddKeyedOpenAIClient("openai");
builder.AddKeyedOpenAIClient("ionos");
```
assuming that at least one keyed OpenAIClient has a differnt endpoint,
```
{
"ConnectionStrings": {
"openai": "Key={account_key};"
"ionos": "Endpoint=https://{openai_rest_api_url};Key={account_key};"
}
}
```
getting the client with
```
var client = serviceProvider.GetRequiredKeyedService<OpenAIClient>("ionos")
```
the client uses the key from the connectionstring but it still has the default enpoint https://api.openai.com/v1
The issue is that ConfigureOpenAI ignores the serviceKey and always get's the default OpenAIClientOptions instead of the one created with optionsName = servicekey.
This makes using keyed OpenAIClients virtually impossible because the main reason having multiple OpenAIClients is having different endpoints.
Fix #9543
* added unit test
* PR feedback
---------
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>1 parent ad5031b commit 79d4eed
File tree
2 files changed
+38
-1
lines changed- src/Components/Aspire.OpenAI
- tests/Aspire.OpenAI.Tests
2 files changed
+38
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
128 | 131 | | |
129 | 132 | | |
130 | 133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
89 | 123 | | |
90 | 124 | | |
91 | 125 | | |
| |||
0 commit comments