Spaces:
Runtime error
Runtime error
Download app.py from Rex165/eugene-intelligence: direct link, hf CLI and curl.
- Browser
- Download file 4.75 kB
-
https://huggingface.co/spaces/Rex165/eugene-intelligence/resolve/main/app.py
- Command line
-
hf download hf://spaces/Rex165/eugene-intelligence/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Rex165/eugene-intelligence/resolve/main/app.py
4.75 kB
| """ | |
| Eugene Intelligence v0.4 — HuggingFace Space | |
| Financial context for AI. Every number traced to source. | |
| """ | |
| import json | |
| import gradio as gr | |
| from eugene.router import query, capabilities, VALID_EXTRACTS | |
| from eugene.sources.fred import get_category, get_series, get_all, FRED_SERIES | |
| from eugene.concepts import VALID_CONCEPTS | |
| VERSION = "0.4.0" | |
| def sec_query(identifier, extract, period, concept, form, section, limit): | |
| if not identifier.strip(): | |
| return json.dumps({"error": "Please enter a ticker, CIK, or accession number."}, indent=2) | |
| params = { | |
| "period": period, | |
| "concept": concept if concept else None, | |
| "form": form if form else None, | |
| "section": section if section else None, | |
| "limit": int(limit), | |
| } | |
| result = query( | |
| identifier.strip().upper(), extract, | |
| **{k: v for k, v in params.items() if v is not None} | |
| ) | |
| return json.dumps(result, indent=2, default=str) | |
| def economics_query(category, series_id): | |
| if series_id and series_id.strip(): | |
| result = get_series(series_id.strip().upper()) | |
| elif category == "all": | |
| result = get_all() | |
| else: | |
| result = get_category(category) | |
| return json.dumps(result, indent=2, default=str) | |
| def get_caps(): | |
| return json.dumps(capabilities(), indent=2) | |
| with gr.Blocks( | |
| title="Eugene Intelligence v0.4", | |
| theme=gr.themes.Base(), | |
| ) as demo: | |
| gr.HTML(""" | |
| <div style="text-align:center;margin-bottom:1rem;"> | |
| <h1>Eugene Intelligence v0.4</h1> | |
| <p style="color:#666;">Financial context for AI. Every number traced to source.</p> | |
| </div> | |
| """) | |
| with gr.Tabs(): | |
| with gr.Tab("SEC EDGAR"): | |
| with gr.Row(): | |
| with gr.Column(scale=1): | |
| identifier = gr.Textbox(label="Identifier", placeholder="AAPL, 320193, or accession number", value="AAPL") | |
| extract = gr.Dropdown(label="Extract", choices=VALID_EXTRACTS, value="financials") | |
| period = gr.Radio(label="Period (financials)", choices=["FY", "Q"], value="FY") | |
| limit = gr.Slider(label="Limit", minimum=1, maximum=20, step=1, value=5) | |
| concept = gr.Textbox(label="Concept (optional)", placeholder="revenue, net_income, eps_diluted...") | |
| form = gr.Textbox(label="Form filter (optional)", placeholder="10-K, 10-Q, 8-K, 4...") | |
| section = gr.Textbox(label="Section (optional)", placeholder="mdna, risk_factors, business...") | |
| sec_btn = gr.Button("Query SEC", variant="primary") | |
| with gr.Column(scale=2): | |
| sec_output = gr.Code(label="Response", language="json", lines=30) | |
| sec_btn.click(fn=sec_query, inputs=[identifier, extract, period, concept, form, section, limit], outputs=sec_output) | |
| gr.Examples( | |
| examples=[ | |
| ["AAPL", "financials", "FY", "", "", "", 5], | |
| ["NVDA", "financials", "FY", "revenue", "", "", 5], | |
| ["TSLA", "profile", "FY", "", "", "", 5], | |
| ["JPM", "filings", "FY", "", "10-K", "", 5], | |
| ["MSFT", "financials", "Q", "", "", "", 8], | |
| ], | |
| inputs=[identifier, extract, period, concept, form, section, limit], | |
| ) | |
| with gr.Tab("Economics (FRED)"): | |
| with gr.Row(): | |
| with gr.Column(scale=1): | |
| econ_category = gr.Dropdown(label="Category", choices=["all","inflation","employment","gdp","housing","consumer","manufacturing","rates","money","treasury"], value="treasury") | |
| econ_series = gr.Textbox(label="Specific series ID (optional)", placeholder="CPIAUCSL, UNRATE, DGS10...") | |
| econ_btn = gr.Button("Query FRED", variant="primary") | |
| with gr.Column(scale=2): | |
| econ_output = gr.Code(label="Response", language="json", lines=30) | |
| econ_btn.click(fn=economics_query, inputs=[econ_category, econ_series], outputs=econ_output) | |
| with gr.Tab("Capabilities"): | |
| caps_btn = gr.Button("Show Capabilities") | |
| caps_output = gr.Code(language="json", lines=30) | |
| caps_btn.click(fn=get_caps, outputs=caps_output) | |
| gr.Markdown(f""" | |
| ### Links | |
| - **GitHub**: [Matthew-Anyiam/eugene-data-labs](https://github.com/Matthew-Anyiam/eugene-data-labs) | |
| - **API**: [eugene-data-labs-production.up.railway.app](https://eugene-data-labs-production.up.railway.app) | |
| - **MCP**: [mcpservers.org](https://mcpservers.org/server/matthew-anyiam/eugene-data-labs) | |
| """) | |
| if __name__ == "__main__": | |
| demo.launch(server_name="0.0.0.0", server_port=7860) | |