File tree Expand file tree Collapse file tree 2 files changed +5
-7
lines changed
Expand file tree Collapse file tree 2 files changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -237,11 +237,11 @@ public function getSimilarChunks($query, $lang = '')
237237
238238 $ time = microtime (true );
239239 $ chunks = $ this ->storage ->getSimilarChunks ($ vector , $ lang , $ fetch );
240- $ this ->timeSpent = microtime (true ) - $ time ;
240+ $ this ->timeSpent = round ( microtime (true ) - $ time, 2 ) ;
241241 if ($ this ->logger instanceof CLI ) {
242242 $ this ->logger ->info (
243243 'Fetched {count} similar chunks from store in {time} seconds ' ,
244- ['count ' => count ($ chunks ), 'time ' => round ( $ this ->timeSpent , 2 ) ]
244+ ['count ' => count ($ chunks ), 'time ' => $ this ->timeSpent ]
245245 );
246246 }
247247
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ public function __construct(string $name, array $config)
2323 /** @inheritdoc */
2424 public function getAnswer (array $ messages ): string
2525 {
26- // convert OpenAI Style to Anthropic style
26+ // system message is separate from the messages array
2727 $ system = '' ;
2828 $ chat = [];
2929 foreach ($ messages as $ message ) {
@@ -47,9 +47,6 @@ public function getAnswer(array $messages): string
4747 }
4848
4949 $ response = $ this ->request ('messages ' , $ data );
50-
51- print_r ($ response );
52-
5350 return $ response ['content ' ][0 ]['text ' ];
5451 }
5552
@@ -71,7 +68,8 @@ protected function request($endpoint, $data)
7168 protected function parseAPIResponse ($ response )
7269 {
7370 if (isset ($ response ['usage ' ])) {
74- $ this ->tokensUsed += $ response ['usage ' ]['input_tokens ' ] + $ response ['usage ' ]['output_tokens ' ];
71+ $ this ->inputTokensUsed += $ response ['usage ' ]['input_tokens ' ];
72+ $ this ->outputTokensUsed += $ response ['usage ' ]['output_tokens ' ];
7573 }
7674
7775 if (isset ($ response ['error ' ])) {
You can’t perform that action at this time.
0 commit comments