Spaces:
Running
Running
| import streamlit as st | |
| from shared.hf_helpers import build_pipeline | |
| import yaml | |
| from pathlib import Path | |
| def main(): | |
| st.title("π° FinanceGPT β Financial Q&A Demo") | |
| CONFIG_PATH = Path(__file__).resolve().parent / "config.yaml" | |
| with open(CONFIG_PATH) as f: | |
| cfg = yaml.safe_load(f) | |
| model_name = st.selectbox("Select model:", [cfg["base_model"], "AxionX/financegpt-sec-sample"]) | |
| def get_pipe(model_name): | |
| return build_pipeline(model_name) | |
| pipe = get_pipe(model_name) | |
| prompt = st.text_area("Enter a financial statement or question:") | |
| if st.button("Generate Answer"): | |
| if prompt.strip(): | |
| result = pipe(prompt, max_new_tokens=cfg["demo"]["max_new_tokens"]) | |
| st.markdown("### π§ Answer") | |
| st.write(result[0]["generated_text"]) | |
| # π So it works standalone or via streamlit_hub.py | |
| if __name__ == "__main__": | |
| main() | |