enhance checky by requesting endpoint propert to be set when apiType is Azure
Signed-off-by: fabistb <fabian0401@online.de>
This commit is contained in:
parent
f7f3dc5c3e
commit
b667ae76eb
|
@ -82,6 +82,11 @@ func (o *OpenAI) Init(ctx context.Context, meta conversation.Metadata) error {
|
|||
return errors.New("apiVersion must be provided when apiType is set to 'azure'")
|
||||
}
|
||||
|
||||
// Return error when api Type is azure but the endpoint is not provided
|
||||
if md.ApiType == "azure" && md.Endpoint == "" {
|
||||
return errors.New("endpoint must be provided when apiType is set to 'azure'")
|
||||
}
|
||||
|
||||
// Set api version if provided
|
||||
if md.ApiVersion != "" {
|
||||
options = append(options, openai.WithAPIVersion(md.ApiVersion))
|
||||
|
|
|
@ -94,6 +94,19 @@ func TestInit(t *testing.T) {
|
|||
assert.EqualError(t, err, "apiVersion must be provided when apiType is set to 'azure'")
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "with apiType azure but missing endpoint",
|
||||
metadata: map[string]string{
|
||||
"key": "test-key",
|
||||
"model": "gpt-4",
|
||||
"apiType": "azure",
|
||||
"apiVersion": "2025-01-01-preview",
|
||||
},
|
||||
testFn: func(t *testing.T, o *OpenAI, err error) {
|
||||
require.Error(t, err)
|
||||
assert.EqualError(t, err, "endpoint must be provided when apiType is set to 'azure'")
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
|
Loading…
Reference in New Issue