@@ -106,18 +106,32 @@ def _execute_standard(self, initial_state: dict) -> Tuple[dict, list]:
106106 source_type = None
107107 llm_model = None
108108 embedder_model = None
109+ source = []
110+ prompt = None
111+ schema = None
109112
110113 while current_node_name :
111114 curr_time = time .time ()
112115 current_node = next (node for node in self .nodes if node .node_name == current_node_name )
113116
117+
114118 # check if there is a "source" key in the node config
115119 if current_node .__class__ .__name__ == "FetchNode" :
116120 # get the second key name of the state dictionary
117121 source_type = list (state .keys ())[1 ]
122+ if state .get ("user_prompt" , None ):
123+ prompt = state ["user_prompt" ] if type (state ["user_prompt" ]) == str else None
118124 # quick fix for local_dir source type
119125 if source_type == "local_dir" :
120126 source_type = "html_dir"
127+ elif source_type == "url" :
128+ if type (state [source_type ]) == list :
129+ # iterate through the list of urls and see if they are strings
130+ for url in state [source_type ]:
131+ if type (url ) == str :
132+ source .append (url )
133+ elif type (state [source_type ]) == str :
134+ source .append (state [source_type ])
121135
122136 # check if there is an "llm_model" variable in the class
123137 if hasattr (current_node , "llm_model" ) and llm_model is None :
@@ -135,6 +149,16 @@ def _execute_standard(self, initial_state: dict) -> Tuple[dict, list]:
135149 elif hasattr (embedder_model , "model" ):
136150 embedder_model = embedder_model .model
137151
152+ if hasattr (current_node , "node_config" ):
153+ if type (current_node .node_config ) is dict :
154+ if current_node .node_config .get ("schema" , None ) and schema is None :
155+ if type (current_node .node_config ["schema" ]) is not dict :
156+ # convert to dict
157+ try :
158+ schema = current_node .node_config ["schema" ].schema ()
159+ except Exception as e :
160+ schema = None
161+
138162 with get_openai_callback () as cb :
139163 try :
140164 result = current_node .execute (state )
@@ -144,11 +168,15 @@ def _execute_standard(self, initial_state: dict) -> Tuple[dict, list]:
144168 graph_execution_time = time .time () - start_time
145169 log_graph_execution (
146170 graph_name = self .graph_name ,
171+ source = source ,
172+ prompt = prompt ,
173+ schema = schema ,
147174 llm_model = llm_model ,
148175 embedder_model = embedder_model ,
149176 source_type = source_type ,
150177 execution_time = graph_execution_time ,
151- error_node = error_node
178+ error_node = error_node ,
179+ exception = str (e )
152180 )
153181 raise e
154182 node_exec_time = time .time () - curr_time
@@ -191,11 +219,16 @@ def _execute_standard(self, initial_state: dict) -> Tuple[dict, list]:
191219
192220 # Log the graph execution telemetry
193221 graph_execution_time = time .time () - start_time
222+ response = state .get ("answer" , None ) if source_type == "url" else None
194223 log_graph_execution (
195224 graph_name = self .graph_name ,
225+ source = source ,
226+ prompt = prompt ,
227+ schema = schema ,
196228 llm_model = llm_model ,
197229 embedder_model = embedder_model ,
198230 source_type = source_type ,
231+ response = response ,
199232 execution_time = graph_execution_time ,
200233 total_tokens = cb_total ["total_tokens" ] if cb_total ["total_tokens" ] > 0 else None ,
201234 )
0 commit comments