@@ -30,13 +30,24 @@ export class LmStudioHandler extends BaseProvider implements SingleCompletionHan
3030 ]
3131
3232 try {
33- const stream = await this . client . chat . completions . create ( {
33+ // Create params object with optional draft model
34+ const params : any = {
3435 model : this . getModel ( ) . id ,
3536 messages : openAiMessages ,
3637 temperature : this . options . modelTemperature ?? LMSTUDIO_DEFAULT_TEMPERATURE ,
3738 stream : true ,
38- } )
39- for await ( const chunk of stream ) {
39+ }
40+
41+ // Add draft model if speculative decoding is enabled and a draft model is specified
42+ if ( this . options . lmStudioSpeculativeDecodingEnabled && this . options . lmStudioDraftModelId ) {
43+ params . draft_model = this . options . lmStudioDraftModelId
44+ }
45+
46+ const results = await this . client . chat . completions . create ( params )
47+
48+ // Stream handling
49+ // @ts -ignore
50+ for await ( const chunk of results ) {
4051 const delta = chunk . choices [ 0 ] ?. delta
4152 if ( delta ?. content ) {
4253 yield {
@@ -62,12 +73,20 @@ export class LmStudioHandler extends BaseProvider implements SingleCompletionHan
6273
6374 async completePrompt ( prompt : string ) : Promise < string > {
6475 try {
65- const response = await this . client . chat . completions . create ( {
76+ // Create params object with optional draft model
77+ const params : any = {
6678 model : this . getModel ( ) . id ,
6779 messages : [ { role : "user" , content : prompt } ] ,
6880 temperature : this . options . modelTemperature ?? LMSTUDIO_DEFAULT_TEMPERATURE ,
6981 stream : false ,
70- } )
82+ }
83+
84+ // Add draft model if speculative decoding is enabled and a draft model is specified
85+ if ( this . options . lmStudioSpeculativeDecodingEnabled && this . options . lmStudioDraftModelId ) {
86+ params . draft_model = this . options . lmStudioDraftModelId
87+ }
88+
89+ const response = await this . client . chat . completions . create ( params )
7190 return response . choices [ 0 ] ?. message . content || ""
7291 } catch ( error ) {
7392 throw new Error (
0 commit comments