@@ -4,15 +4,15 @@ import { ChatOpenAI } from "@langchain/openai";
44import { HumanMessage , AIMessage } from "@langchain/core/messages" ;
55import { ToolNode } from "@langchain/langgraph/prebuilt" ;
66import { StateGraph , MessagesAnnotation } from "@langchain/langgraph" ;
7- import { get } from "http" ;
87
98// Define the tools for the agent to use
109const tools = [ new TavilySearch ( { maxResults : 3 } ) ] ;
1110const toolNode = new ToolNode ( tools ) ;
1211
1312const baseUrl = process . env . LLM_URL || "https://api.openai.com/v1/" ;
13+ console . log ( "Using LLM base URL:" , baseUrl ) ;
1414const baseModel = process . env . LLM_MODEL || "gpt-4o-mini" ;
15-
15+ console . log ( "Using LLM model:" , baseModel ) ;
1616// Create a model and give it access to the tools
1717const model = new ChatOpenAI ( {
1818 model : baseModel ,
@@ -56,9 +56,13 @@ const app = workflow.compile();
5656
5757// Helper function to get agent output for a given input and optional previous messages
5858const getAgentOutput = async ( input : string , previousMessages : ( HumanMessage | AIMessage ) [ ] = [ ] ) => {
59+ console . log ( "Getting agent output for input:" , input ) ;
60+
5961 const initialState = {
6062 messages : [ ...previousMessages , new HumanMessage ( input ) ] ,
6163 } ;
64+ console . log ( "Initial state messages (JSON):" , JSON . stringify ( initialState . messages , null , 2 ) ) ;
65+
6266 const finalState = await app . invoke ( initialState ) ;
6367 return {
6468 content : finalState . messages [ finalState . messages . length - 1 ] . content ,
0 commit comments