Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from core.buzzure import fetch_topics_from_sheet | |
| from core.cohere_engine import generate_post | |
| def build_ui(): | |
| topic_choices = fetch_topics_from_sheet() | |
| print(f"✅ Fetched Topics from Sheet: {topic_choices}") # Debug log | |
| if not topic_choices: | |
| topic_choices = ["General"] | |
| # NEW: Free-text input that overrides dropdown if filled | |
| manual_topic = gr.Textbox(label="Or type your own topic", placeholder="Write anything...") | |
| # Existing dropdown | |
| topic = gr.Dropdown(label="Choose from latest topics", choices=topic_choices, value=topic_choices[0]) | |
| tone = gr.Dropdown(label="Tone", choices=["Professional", "Witty", "Empathetic"], value="Professional") | |
| platform = gr.Dropdown(label="Platform", choices=["LinkedIn", "Instagram", "Twitter"], value="LinkedIn") | |
| length = gr.Dropdown(label="Length", choices=["Short", "Medium", "Long"], value="Medium") | |
| output = gr.Textbox(label="Generated Post", lines=8) | |
| def generate_with_fallback(manual_topic_text, dropdown_topic, tone, platform, length): | |
| final_topic = manual_topic_text.strip() if manual_topic_text.strip() else dropdown_topic | |
| return generate_post(final_topic, tone, platform, length) | |
| interface = gr.Interface( | |
| fn=generate_with_fallback, | |
| inputs=[manual_topic, topic, tone, platform, length], | |
| outputs=output, | |
| title="🧠 Buzzure Oxygen Engine", | |
| description="Pick a topic or type your own — and let the fire fly!" | |
| ) | |
| return interface | |
| if __name__ == "__main__": | |
| demo = build_ui() | |
| demo.launch() | |