This repository was archived by the owner on Jul 4, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +17
-4
lines changed
Expand file tree Collapse file tree 6 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { firstValueFrom } from 'rxjs';
55
66export abstract class OAIEngineExtension extends EngineExtension {
77 abstract apiUrl : string ;
8+ abstract apiKey ?: string ;
89
910 constructor ( protected readonly httpService : HttpService ) {
1011 super ( ) ;
@@ -21,7 +22,9 @@ export abstract class OAIEngineExtension extends EngineExtension {
2122 this . httpService . post ( this . apiUrl , createChatDto , {
2223 headers : {
2324 'Content-Type' : headers [ 'content-type' ] ?? 'application/json' ,
24- Authorization : headers [ 'authorization' ] ,
25+ Authorization : this . apiKey
26+ ? `Bearer ${ this . apiKey } `
27+ : headers [ 'authorization' ] ,
2528 } ,
2629 responseType : stream ? 'stream' : 'json' ,
2730 } ) ,
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ export default class GroqEngineExtension extends OAIEngineExtension {
1313 productName = 'Groq Inference Engine' ;
1414 description = 'This extension enables fast Groq chat completion API calls' ;
1515 version = '0.0.1' ;
16+ apiKey ?: string ;
1617
1718 constructor (
1819 protected readonly httpService : HttpService ,
@@ -25,6 +26,8 @@ export default class GroqEngineExtension extends OAIEngineExtension {
2526 const configs = ( await this . configsUsecases . getGroupConfigs (
2627 this . name ,
2728 ) ) as unknown as { apiKey : string } ;
29+
30+ this . apiKey = configs ?. apiKey
2831 if ( ! configs ?. apiKey )
2932 await this . configsUsecases . saveConfig ( 'apiKey' , '' , this . name ) ;
3033 }
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ export default class MistralEngineExtension extends OAIEngineExtension {
1313 productName = 'Mistral Inference Engine' ;
1414 description = 'This extension enables Mistral chat completion API calls' ;
1515 version = '0.0.1' ;
16+ apiKey ?: string ;
1617
1718 constructor (
1819 protected readonly httpService : HttpService ,
@@ -25,6 +26,7 @@ export default class MistralEngineExtension extends OAIEngineExtension {
2526 const configs = ( await this . configsUsecases . getGroupConfigs (
2627 this . name ,
2728 ) ) as unknown as { apiKey : string } ;
29+ this . apiKey = configs ?. apiKey ;
2830 if ( ! configs ?. apiKey )
2931 await this . configsUsecases . saveConfig ( 'apiKey' , '' , this . name ) ;
3032 }
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ export default class OpenAIEngineExtension extends OAIEngineExtension {
1313 productName = 'OpenAI Inference Engine' ;
1414 description = 'This extension enables OpenAI chat completion API calls' ;
1515 version = '0.0.1' ;
16+ apiKey ?: string ;
1617
1718 constructor (
1819 protected readonly httpService : HttpService ,
@@ -25,6 +26,7 @@ export default class OpenAIEngineExtension extends OAIEngineExtension {
2526 const configs = ( await this . configsUsecases . getGroupConfigs (
2627 this . name ,
2728 ) ) as unknown as { apiKey : string } ;
29+ this . apiKey = configs ?. apiKey ;
2830 if ( ! configs ?. apiKey )
2931 await this . configsUsecases . saveConfig ( 'apiKey' , '' , this . name ) ;
3032 }
Original file line number Diff line number Diff line change @@ -192,7 +192,7 @@ export class ChatCliUsecases {
192192 const toParse = cachedLines + line ;
193193 if ( ! line . includes ( 'data: [DONE]' ) ) {
194194 const data = JSON . parse ( toParse . replace ( 'data: ' , '' ) ) ;
195- content + = data . choices [ 0 ] ?. delta ?. content ?? '' ;
195+ content = data . choices [ 0 ] ?. delta ?. content ?? '' ;
196196
197197 if ( content . startsWith ( 'assistant: ' ) ) {
198198 content = content . replace ( 'assistant: ' , '' ) ;
@@ -209,8 +209,10 @@ export class ChatCliUsecases {
209209 }
210210 } ) ;
211211 } )
212- . catch ( ( ) => {
213- stdout . write ( 'Something went wrong! Please check model status.\n' ) ;
212+ . catch ( ( e : any ) => {
213+ stdout . write (
214+ `Something went wrong! Please check model status.\n${ e . message } \n` ,
215+ ) ;
214216 if ( attach ) rl . prompt ( ) ;
215217 else rl . close ( ) ;
216218 } ) ;
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ export default class CortexProvider extends OAIEngineExtension {
2121 description =
2222 'This extension enables chat completion API calls using the Cortex engine' ;
2323 version = '0.0.1' ;
24+ apiKey ?: string | undefined ;
2425
2526 private loadModelUrl = `http://${ defaultCortexCppHost } :${ defaultCortexCppPort } /inferences/server/loadmodel` ;
2627 private unloadModelUrl = `http://${ defaultCortexCppHost } :${ defaultCortexCppPort } /inferences/server/unloadmodel` ;
You can’t perform that action at this time.
0 commit comments