File size: 4,748 Bytes
80b6d68
3a3a58f
 
80b6d68
3a3a58f
80b6d68
3a3a58f
 
 
cde8112
3a3a58f
50cf8db
3a3a58f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29d192d
50cf8db
3a3a58f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50cf8db
29d192d
3a3a58f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29d192d
3a3a58f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
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)