1616using BotSharp . Abstraction . Conversations . Models ;
1717using Microsoft . AspNetCore . Authorization ;
1818using BotSharp . Abstraction . Agents . Enums ;
19+ using BotSharp . Abstraction . MLTasks ;
20+ using BotSharp . Abstraction . MLTasks . Settings ;
1921
2022namespace BotSharp . Plugin . ChatbotUI . Controllers ;
2123
@@ -35,27 +37,18 @@ public ChatbotUiController(ILogger<ChatbotUiController> logger, IServiceProvider
3537 [ HttpGet ( "/v1/models" ) ]
3638 public OpenAiModels GetOpenAiModels ( )
3739 {
40+ var llm = _services . GetRequiredService < ILlmProviderService > ( ) ;
41+ var models = llm . GetProviderModels ( "azure-openai" ) . Where ( x => x . Type == LlmModelType . Chat )
42+ . Select ( x => new AiModel
43+ {
44+ Id = x . Id ,
45+ Model = x . Name ,
46+ Name = x . Name
47+ } ) . ToList ( ) ;
48+
3849 return new OpenAiModels
3950 {
40- Data = new List < AiModel >
41- {
42- new AiModel
43- {
44- Id = "gpt-3.5-turbo" ,
45- Model = "gpt-3.5-turbo" ,
46- Name = "GPT-3.5 Turbo" ,
47- MaxLength = 4 * 1024 ,
48- TokenLimit = 4 * 1024
49- } ,
50- new AiModel
51- {
52- Id = "gpt-4" ,
53- Model = "gpt-4" ,
54- Name = "GPT-4" ,
55- MaxLength = 8 * 1024 ,
56- TokenLimit = 8 * 1024
57- }
58- }
51+ Data = models ,
5952 } ;
6053 }
6154
@@ -73,11 +66,16 @@ public async Task SendMessage([FromBody] OpenAiMessageInput input)
7366 . Select ( x => new RoleDialogModel ( x . Role , x . Content ) )
7467 . Last ( ) ;
7568
69+ var llm = _services . GetRequiredService < ILlmProviderService > ( ) ;
70+ var model = llm . GetProviderModels ( "azure-openai" )
71+ . First ( x => x . Type == LlmModelType . Chat && x . Id == input . Model )
72+ . Name ;
73+
7674 var conv = _services . GetRequiredService < IConversationService > ( ) ;
7775 conv . SetConversationId ( input . ConversationId , input . States ) ;
7876 conv . States . SetState ( "channel" , input . Channel )
79- . SetState ( "provider" , input . Provider )
80- . SetState ( "model" , input . Model )
77+ . SetState ( "provider" , "azure-openai" )
78+ . SetState ( "model" , model )
8179 . SetState ( "temperature" , input . Temperature )
8280 . SetState ( "sampling_factor" , input . SamplingFactor ) ;
8381
0 commit comments