1
1
import type { ChatMessage } from "llamaindex" ;
2
2
import { OpenAIAgent } from "llamaindex" ;
3
3
import { DynamicContextData , gatherContextData } from "../cli/contextUtils" ;
4
- import { LLM_ID , MESSAGE_ROLES , MODEL_PRICES } from "../constants" ;
4
+ import { MESSAGE_ROLES , MODELS , WEAK_MODEL_ID } from "../constants" ;
5
5
import { getCorrectness , getFaithfulness , getRelevancy } from "../features/userScore/evaluations/evaluations" ;
6
6
import { getUserEvaluationScore } from "../features/userScore/getUserEvaluationScore" ;
7
7
import { askUserCallback } from "../tools/askUser" ;
@@ -16,7 +16,7 @@ import {
16
16
} from "../utils/database" ;
17
17
import { formatAgentMessage } from "../utils/formatting" ;
18
18
import { generateConversationTitle } from "../utils/generateConversationTitle" ;
19
- import { getApiKeyForModel , getOrPromptForAPIKey } from "../utils/getOrPromptForAPIKey" ;
19
+ import { getOrPromptForAPIKey } from "../utils/getOrPromptForAPIKey" ;
20
20
import { UsageCostResult } from "../utils/interface" ;
21
21
import { logger , LogLevel , LogLevelType } from "../utils/logger" ;
22
22
import { parseLLMResponse } from "../utils/parseLLMResponse" ;
@@ -107,7 +107,7 @@ export async function runAgent(
107
107
if ( input === "<input_aborted_by_user />" ) {
108
108
input = "<service_message>User expressed explicit intent to exit the program.</service_message>" ;
109
109
}
110
- const apiKey = await getApiKeyForModel ( model ) ;
110
+ const apiKey = await getOrPromptForAPIKey ( model ) ;
111
111
if ( ! apiKey ) {
112
112
logger . error ( "No API key found" ) ;
113
113
throw new Error ( "LLM API key not found. Please run the application again to set it up." ) ;
@@ -278,8 +278,8 @@ async function finalizeAgentRun(
278
278
279
279
logger . debug ( "Generating conversation title" ) ;
280
280
const title = await generateConversationTitle ( fullConversation , {
281
- apiKey : await getOrPromptForAPIKey ( LLM_ID ) ,
282
- modelName : LLM_ID ,
281
+ apiKey : await getOrPromptForAPIKey ( WEAK_MODEL_ID ) ,
282
+ modelName : WEAK_MODEL_ID ,
283
283
} ) ;
284
284
285
285
logger . debug ( "Getting user evaluation score" ) ;
@@ -306,7 +306,7 @@ async function finalizeAgentRun(
306
306
307
307
function countUsageCost ( usage : Record < string , number > , model : string ) : UsageCostResult {
308
308
// Get model pricing from the current model being used
309
- const modelConfig = MODEL_PRICES [ model ] ?? MODEL_PRICES [ "gpt-4o-mini" ] ; // fallback to a default model
309
+ const modelConfig = MODELS [ model ] ?? MODELS [ "gpt-4o-mini" ] ; // fallback to a default model
310
310
311
311
// Normalize token counts from different possible field names
312
312
const inputTokens = usage . input_tokens || usage . prompt_tokens || 0 ;
0 commit comments