(
use_llm_func, embeddings_func, \
clusters,label,nodes,community_report_prompt,\
relations,generate_relations,layer,temp_clusters_nodes
)
| 402 | {edges_describe} |
| 403 | ```""" |
| 404 | def process_cluster( |
| 405 | use_llm_func, embeddings_func, \ |
| 406 | clusters,label,nodes,community_report_prompt,\ |
| 407 | relations,generate_relations,layer,temp_clusters_nodes |
| 408 | ): |
| 409 | indices = [i for i, cluster in enumerate(clusters) if label in cluster] |
| 410 | # Add the corresponding nodes to the node_clusters list |
| 411 | cluster_nodes = [nodes[i] for i in indices] |
| 412 | |
| 413 | # Base case: if the cluster only has one node, do not attempt to recluster it |
| 414 | logging.info(f"[Label{str(int(label))} Size: {len(cluster_nodes)}]") |
| 415 | if len(cluster_nodes) == 1: |
| 416 | cluster_nodes[0]['parent']=cluster_nodes[0]['entity_name'] |
| 417 | return { |
| 418 | 'community_data': None, |
| 419 | 'temp_node': cluster_nodes[0], |
| 420 | 'index':indices |
| 421 | } |
| 422 | name_set=[node['entity_name'] for node in cluster_nodes] |
| 423 | cluster_intern_relation={**get_direct_relations(name_set,name_set,relations), |
| 424 | **get_direct_relations(name_set,name_set,generate_relations)} |
| 425 | describe=_pack_single_community_describe(cluster_nodes,cluster_intern_relation) |
| 426 | hint_prompt=community_report_prompt.format(input_text=describe) |
| 427 | response = use_llm_func(hint_prompt) |
| 428 | data = convert_response_to_json(response) |
| 429 | data['level'] = layer |
| 430 | data['children'] = [n['entity_name'] for n in cluster_nodes] |
| 431 | data['source_id'] = "|".join(set([n['source_id'] for n in cluster_nodes])) |
| 432 | |
| 433 | temp_node = { |
| 434 | 'entity_name': data['entity_name'], |
| 435 | 'description': data['entity_description'], |
| 436 | 'source_id': data['source_id'], |
| 437 | 'entity_type': "aggregate entity", |
| 438 | 'degree': 1, |
| 439 | 'vector': embeddings_func(data['entity_description']), |
| 440 | } |
| 441 | |
| 442 | |
| 443 | return { |
| 444 | 'community_data': data, |
| 445 | 'temp_node': temp_node, |
| 446 | 'index':indices |
| 447 | } |
| 448 | def process_relation( |
| 449 | use_llm_func,community_report,maybe_edge,relations,generate_relations,\ |
| 450 | cluster_cluster_relation_prompt,layer,tokenizer,max_depth |
nothing calls this directly
no test coverage detected