Spaces:
Paused
Paused
Armando Medina commited on
Update src/streamlit_app.py
Browse files84 unmodified lines8586878889909192939495969784 unmodified linesdef retrieve_relevant_entities(query, top_k=5):query_emb = embedder.encode([query], convert_to_numpy=True).tolist()results = collection.query(query_embeddings=query_emb, n_results=top_k)return results['ids'][0]def expand_graph_context(graph, entities, depth=1):subgraph_nodes = set(entities)for entity in entities:neighbors = nx.single_source_shortest_path_length(graph, entity, cutoff=depth).keys()subgraph_nodes.update(neighbors)return graph.subgraph(subgraph_nodes)def format_graph_context(subgraph):84 unmodified lines858687888990919293949596979884 unmodified linesdef retrieve_relevant_entities(query, top_k=5):query_emb = embedder.encode([query], convert_to_numpy=True).tolist()results = collection.query(query_embeddings=query_emb, n_results=top_k)return [match for match in results['ids'][0] if match in collection.peek()['ids']]def expand_graph_context(graph, entities, depth=1):subgraph_nodes = set()for entity in entities:if entity in graph:neighbors = nx.single_source_shortest_path_length(graph, entity, cutoff=depth).keys()subgraph_nodes.update(neighbors)return graph.subgraph(subgraph_nodes)def format_graph_context(subgraph):
src/streamlit_app.py+5-4