@@ -29,7 +29,7 @@ const VERCEL_AI_SHARED_OPTIONS = {
29
29
} ,
30
30
} ;
31
31
32
- export type VercelChatModelAdapterOptions = {
32
+ export type VercelChatModelAdapterConfig = {
33
33
languageModel : LanguageModel ;
34
34
maxTokens ?: number ;
35
35
maxSteps ?: number ;
@@ -51,7 +51,15 @@ type AiExecutionResult = {
51
51
} ;
52
52
53
53
export class VercelChatModelAdapter implements ChatModel {
54
- constructor ( private readonly _options : VercelChatModelAdapterOptions ) { }
54
+ config : VercelChatModelAdapterConfig ;
55
+
56
+ constructor ( config : VercelChatModelAdapterConfig ) {
57
+ this . config = config ;
58
+ }
59
+
60
+ get name ( ) : string {
61
+ return this . config . languageModel . modelId ;
62
+ }
55
63
56
64
async generateResponse ( context : RequestContext ) : Promise < AssistantResponse > {
57
65
let systemPrompt = context . systemPrompt ( ) ;
@@ -123,10 +131,10 @@ export class VercelChatModelAdapter implements ChatModel {
123
131
const startTime = performance . now ( ) ;
124
132
const result = await streamText ( {
125
133
...VERCEL_AI_SHARED_OPTIONS ,
126
- model : this . _options . languageModel ,
134
+ model : this . config . languageModel ,
135
+ maxTokens : this . config . maxTokens ,
136
+ maxSteps : this . config . maxSteps ,
127
137
messages : context . messages ,
128
- maxTokens : this . _options . maxTokens ,
129
- maxSteps : this . _options . maxSteps ,
130
138
tools : context . tools ,
131
139
} ) ;
132
140
@@ -156,10 +164,10 @@ export class VercelChatModelAdapter implements ChatModel {
156
164
const startTime = performance . now ( ) ;
157
165
const result = await generateText ( {
158
166
...VERCEL_AI_SHARED_OPTIONS ,
159
- model : this . _options . languageModel ,
167
+ model : this . config . languageModel ,
168
+ maxTokens : this . config . maxTokens ,
169
+ maxSteps : this . config . maxSteps ,
160
170
messages : context . messages ,
161
- maxTokens : this . _options . maxTokens ,
162
- maxSteps : this . _options . maxSteps ,
163
171
tools : context . tools ,
164
172
} ) ;
165
173
const responseTime = performance . now ( ) - startTime ;
0 commit comments