Skip to content

Commit 8ce7288

Browse files
chore: throw exception in the case where a model can't be determined
1 parent a9a3c6d commit 8ce7288

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

packages/sdk/server-ai/src/LDAIConfigMapper.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ export class LDAIConfigMapper {
3737
} else {
3838
model = provider[this._provider?.name ?? '']?.(this._model?.name ?? '');
3939
}
40+
if (!model) {
41+
throw new Error(
42+
'Vercel AI SDK model cannot be determined from the supplied provider parameter.',
43+
);
44+
}
4045

4146
let messages: LDMessage[] | undefined;
4247
if (this._messages || options?.nonInterpolatedMessages) {

packages/sdk/server-ai/src/api/config/LDAIConfig.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,12 @@ export interface LDAIConfig {
7474
* Maps this AI config to a format usable direcly in Vercel AI SDK generateText()
7575
* and streamText() methods.
7676
*
77+
* WARNING: this method can throw an exception if a Vercel AI SDK model cannot be determined.
78+
*
7779
* @param provider A Vercel AI SDK Provider or a map of provider names to Vercel AI SDK Providers.
7880
* @param options Optional mapping options.
7981
* @returns A configuration directly usable in Vercel AI SDK generateText() and streamText()
82+
* @throws {Error} if a Vercel AI SDK model cannot be determined from the given provider parameter.
8083
*/
8184
toVercelAISDK: <TMod>(
8285
provider: VercelAISDKProvider<TMod> | Record<string, VercelAISDKProvider<TMod>>,

0 commit comments

Comments
 (0)