17
17
import logging
18
18
from contextlib import suppress
19
19
from time import time
20
+ from typing import Any
20
21
21
22
import pydantic
22
23
from pydantic import BaseModel
@@ -324,16 +325,17 @@ async def resolve_extracted_node(
324
325
else [],
325
326
}
326
327
327
- summary_context = {
328
+ summary_context : dict [ str , Any ] = {
328
329
'node_name' : extracted_node .name ,
329
330
'node_summary' : extracted_node .summary ,
330
331
'episode_content' : episode .content if episode is not None else '' ,
331
332
'previous_episodes' : [ep .content for ep in previous_episodes ]
332
333
if previous_episodes is not None
333
334
else [],
334
- 'attributes' : [],
335
335
}
336
336
337
+ attributes : list [dict [str , str ]] = []
338
+
337
339
entity_type_classes : tuple [BaseModel , ...] = tuple ()
338
340
if entity_types is not None : # type: ignore
339
341
entity_type_classes = entity_type_classes + tuple (
@@ -344,8 +346,15 @@ async def resolve_extracted_node(
344
346
)
345
347
346
348
for entity_type in entity_type_classes :
347
- for field_name in entity_type .model_fields :
348
- summary_context .get ('attributes' , []).append (field_name ) # type: ignore
349
+ for field_name , field_info in entity_type .model_fields .items ():
350
+ attributes .append (
351
+ {
352
+ 'attribute_name' : field_name ,
353
+ 'attribute_description' : field_info .description or '' ,
354
+ }
355
+ )
356
+
357
+ summary_context ['attributes' ] = attributes
349
358
350
359
entity_attributes_model = pydantic .create_model ( # type: ignore
351
360
'EntityAttributes' ,
0 commit comments