@@ -92,14 +92,18 @@ function countMessages(msgs: ChatMessage[]) {
92
92
}
93
93
94
94
function fillTemplateWith ( input : string , modelConfig : ModelConfig ) {
95
- const cutoff = KnowledgeCutOffDate [ modelConfig . model ] ?? KnowledgeCutOffDate . default ;
95
+ const cutoff =
96
+ KnowledgeCutOffDate [ modelConfig . model ] ?? KnowledgeCutOffDate . default ;
96
97
// Find the model in the DEFAULT_MODELS array that matches the modelConfig.model
97
- const modelInfo = DEFAULT_MODELS . find ( m => m . name === modelConfig . model ) ;
98
- if ( ! modelInfo ) {
99
- throw new Error ( `Model ${ modelConfig . model } not found in DEFAULT_MODELS array.` ) ;
98
+ const modelInfo = DEFAULT_MODELS . find ( ( m ) => m . name === modelConfig . model ) ;
99
+
100
+ var serviceProvider = "OpenAI" ;
101
+ if ( modelInfo ) {
102
+ // TODO: auto detect the providerName from the modelConfig.model
103
+
104
+ // Directly use the providerName from the modelInfo
105
+ serviceProvider = modelInfo . provider . providerName ;
100
106
}
101
- // Directly use the providerName from the modelInfo
102
- const serviceProvider = modelInfo . provider . providerName ;
103
107
104
108
const vars = {
105
109
ServiceProvider : serviceProvider ,
@@ -119,7 +123,7 @@ function fillTemplateWith(input: string, modelConfig: ModelConfig) {
119
123
}
120
124
121
125
Object . entries ( vars ) . forEach ( ( [ name , value ] ) => {
122
- const regex = new RegExp ( `{{${ name } }}` , 'g' ) ;
126
+ const regex = new RegExp ( `{{${ name } }}` , "g" ) ;
123
127
output = output . replace ( regex , value . toString ( ) ) ; // Ensure value is a string
124
128
} ) ;
125
129
0 commit comments