11<?php
22
3+ use dokuwiki \HTTP \DokuHTTPClient ;
34use dokuwiki \plugin \aichat \AbstractCLI ;
45use splitbrain \phpcli \Options ;
56
@@ -25,7 +26,6 @@ protected function main(Options $options)
2526 parent ::main ($ options );
2627
2728 switch ($ options ->getCmd ()) {
28-
2929 case 'update ' :
3030 $ this ->updateModelData ();
3131 break ;
@@ -37,7 +37,7 @@ protected function main(Options $options)
3737 protected function updateModelData ()
3838 {
3939
40- $ http = new \ dokuwiki \ HTTP \ DokuHTTPClient ();
40+ $ http = new DokuHTTPClient ();
4141 $ url = 'https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json ' ;
4242 $ response = $ http ->get ($ url );
4343 if ($ response === false ) {
@@ -84,7 +84,7 @@ protected function updateModelData()
8484 if (!isset ($ ourProviders [$ data ['litellm_provider ' ]])) continue ;
8585 if (!in_array ($ data ['mode ' ], ['chat ' , 'embedding ' ])) continue ;
8686 $ provider = $ data ['litellm_provider ' ];
87- $ model = explode ('/ ' , $ model );
87+ $ model = explode ('/ ' , ( string ) $ model );
8888 $ model = array_pop ($ model );
8989
9090 if (isset ($ ourProviders [$ provider ]['skip ' ]) && preg_match ($ ourProviders [$ provider ]['skip ' ], $ model )) {
@@ -103,13 +103,11 @@ protected function updateModelData()
103103 if ($ data ['mode ' ] === 'chat ' ) {
104104 $ newmodel ['outputTokens ' ] = $ data ['max_output_tokens ' ];
105105 $ newmodel ['outputTokenPrice ' ] = round ($ data ['output_cost_per_token ' ] * 1_000_000 , 2 );
106+ } elseif (isset ($ oldmodel ['dimensions ' ])) {
107+ $ newmodel ['dimensions ' ] = $ oldmodel ['dimensions ' ];
106108 } else {
107- if (isset ($ oldmodel ['dimensions ' ])) {
108- $ newmodel ['dimensions ' ] = $ oldmodel ['dimensions ' ];
109- } else {
110- $ this ->warning ('No dimensions for ' . $ provider . ' ' . $ model . '. Check manually! ' );
111- $ newmodel ['dimensions ' ] = 1536 ;
112- }
109+ $ this ->warning ('No dimensions for ' . $ provider . ' ' . $ model . '. Check manually! ' );
110+ $ newmodel ['dimensions ' ] = 1536 ;
113111 }
114112 $ ourProviders [$ provider ]['models ' ][$ data ['mode ' ]][$ model ] = $ newmodel ;
115113 }
0 commit comments