@@ -363,23 +363,6 @@ func embeddingsEndpoint(cm *ConfigMerger, o *Option) func(c *fiber.Ctx) error {
363
363
}
364
364
365
365
func chatEndpoint (cm * ConfigMerger , o * Option ) func (c * fiber.Ctx ) error {
366
- // TODO: replace this with config settings
367
- // Allow the user to set custom actions via config file
368
- // to be "embedded" in each model
369
- const noActionName = "answer"
370
- const noActionDescription = "use this action to answer without performing any action"
371
-
372
- noActionGrammar := grammar.Function {
373
- Name : noActionName ,
374
- Description : noActionDescription ,
375
- Parameters : map [string ]interface {}{
376
- "properties" : map [string ]interface {}{
377
- "message" : map [string ]interface {}{
378
- "type" : "string" ,
379
- "description" : "The message to reply the user with" ,
380
- }},
381
- },
382
- }
383
366
384
367
process := func (s string , req * OpenAIRequest , config * Config , loader * model.ModelLoader , responses chan OpenAIResponse ) {
385
368
initialMessage := OpenAIResponse {
@@ -416,16 +399,40 @@ func chatEndpoint(cm *ConfigMerger, o *Option) func(c *fiber.Ctx) error {
416
399
}
417
400
log .Debug ().Msgf ("Configuration read: %+v" , config )
418
401
402
+ // Allow the user to set custom actions via config file
403
+ // to be "embedded" in each model
404
+ noActionName := "answer"
405
+ noActionDescription := "use this action to answer without performing any action"
406
+
407
+ if config .FunctionsConfig .NoActionFunctionName != "" {
408
+ noActionName = config .FunctionsConfig .NoActionFunctionName
409
+ }
410
+ if config .FunctionsConfig .NoActionDescriptionName != "" {
411
+ noActionDescription = config .FunctionsConfig .NoActionDescriptionName
412
+ }
413
+
419
414
// process functions if we have any defined or if we have a function call string
420
415
if len (input .Functions ) > 0 &&
421
416
((config .functionCallString != "none" || config .functionCallString == "" ) || len (config .functionCallNameString ) > 0 ) {
422
417
log .Debug ().Msgf ("Response needs to process functions" )
423
418
424
419
processFunctions = true
425
420
421
+ noActionGrammar := grammar.Function {
422
+ Name : noActionName ,
423
+ Description : noActionDescription ,
424
+ Parameters : map [string ]interface {}{
425
+ "properties" : map [string ]interface {}{
426
+ "message" : map [string ]interface {}{
427
+ "type" : "string" ,
428
+ "description" : "The message to reply the user with" ,
429
+ }},
430
+ },
431
+ }
432
+
426
433
// Append the no action function
427
434
funcs = append (funcs , input .Functions ... )
428
- if ! config .DisableDefaultAnswer {
435
+ if ! config .FunctionsConfig . DisableNoAction {
429
436
funcs = append (funcs , noActionGrammar )
430
437
}
431
438
0 commit comments