File size: 5,230 Bytes
52220ed 6e10d6c 52220ed 6e10d6c 6ecf0b3 facd15b 6ecf0b3 facd15b 6e10d6c 3f32357 6e10d6c beb784a 3f32357 b24115b 3f32357 6e10d6c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
---
title: Florentine Families Graph
emoji: 🌍
colorFrom: indigo
colorTo: blue
sdk: gradio
sdk_version: 5.12.0
app_file: app.py
pinned: false
license: cc-by-sa-4.0
---
Here’s a compelling README for your application:
---
# Florentine Families Network Analysis
Welcome to the **Florentine Families Network Analysis Tool**
- a simple yet powerful prototype designed to analyze the [Florentine family network](https://networkx.org/documentation/stable/reference/generated/networkx.generators.social.florentine_families_graph.html#) using graph-based metrics.
- integrates **Smolagents**, **Arize Phoenix**, and **NetworkX** to explore the relationships and centrality dynamics of Renaissance-era Florence families.
- the `app.py` code is a little out of date but I left it `as is` as it showcased where effective telemetry can bring immediate visibility to the impact of minor changes in the tool definition
NOTE: Smolagents has some cool features like [reusable tools](https://huggingface.co/spaces/dwb2023/florentine-families-graph/blob/main/huggingface_spaces_tool_template.md) - but as expected there are some growing pains
## Key Features
### 1. **Smolagents for Agentic Intelligence**
- Employs **Smolagents** to power agentic workflows with multi-step reasoning and secure code execution.
- Uses the **CodeAgent** to execute Python-based tool calls, enabling dynamic interactions with graph data.
- Integrates tools like centrality calculators and visualization functions, allowing users to explore the network effectively.
### 2. **NetworkX for Graph Analysis**
- Leverages the **Florentine Families** dataset from **NetworkX**, a classic representation of Renaissance family alliances.
- Computes critical centrality metrics such as:
- **Degree Centrality**: Identifies the most connected families.
- **Betweenness Centrality**: Highlights families bridging other relationships.
- **Closeness Centrality**: Finds families with optimal influence in the network.
- Provides visual insights into the network structure, helping uncover pivotal roles in Florence's social fabric.
### 3. **Arize Phoenix for Telemetry and Debugging**
- Integrates with **Arize Phoenix** via OpenTelemetry, ensuring robust tracking and inspection of agent workflows.
- Logs agent actions, tool calls, and errors, enabling users to debug and optimize their queries.
- Supports analysis of user interactions and system performance through intuitive dashboards.
### 4. **Interactive Gradio Interface**
- Provides a user-friendly interface for inputting queries and viewing results.
- Predefined examples guide users to explore the centrality roles of key families like the Medici and Strozzi.
- Displays results in textual and visual formats for enhanced comprehension.
---
## How It Works
1. **Input Your Query**: Use natural language to describe your analysis goals (e.g., *"Highlight the Medici family's role using betweenness centrality."*).
2. **Agentic Reasoning**: The **CodeAgent** formulates the necessary computations and retrieves insights using NetworkX and predefined tools.
3. **Graph Analysis**: Metrics are computed and analyzed in real-time, with visualizations optionally generated using tools like **PyVis**.
4. **Telemetry Monitoring**: Every interaction is logged and monitored via Arize Phoenix, providing transparency and debugging capabilities.
---
## Examples
### Analyze Medici's Central Role
```text
"Highlight the Medici family's central role in the network using all three centrality metrics."
```
### Explore the Strozzi Family
```text
"Focus on the Strozzi family's role in the network using betweenness centrality."
```
### Compare Families
```text
"Compare family positions in the network using degree and closeness centrality."
```
#### Overview of 6 CodeAgent runs
![arize-phonix-telemetry](arize_pheonix_6_codeagent_runs.png)
#### Code Generated to create HTML
![arize-phoenix-telemetry-detail-code-html](arize_phoenix_file_image_html.png)
- [html-output](centrality_network.html)
---
## Setup Instructions
### Prerequisites
- Python 3.8 or higher
- Hugging Face API Token (`HF_TOKEN`)
- Arize Phoenix API Key (`PHOENIX_API_KEY`)
### Installation
1. Clone this repository.
2. Install dependencies:
```bash
pip install -r requirements.txt
```
3. Export environment variables:
```bash
export HF_TOKEN=your_hf_api_token
export PHOENIX_API_KEY=your_phoenix_api_key
```
4. Run the app:
```bash
python app.py
```
---
## Technology Stack
- **Smolagents**: For agentic workflows and secure execution.
- **NetworkX**: For robust graph-based computations.
- **Arize Phoenix**: For monitoring and telemetry via OpenTelemetry.
- **Gradio**: For an intuitive user interface.
- **PyVis**: For interactive graph visualizations.
---
## Contributing
We welcome contributions! Please submit issues or pull requests for enhancements or bug fixes.
---
## License
This project is licensed under cc-by-sa-4.0.
---
## Acknowledgments
- Smolagents by Hugging Face
- NetworkX for their graph library and Florentine family dataset
- Arize Phoenix for telemetry insights that accelerated the alignment of LLM behavior |