Spaces:
Running
Running
File size: 2,480 Bytes
e8da79a d015f88 e8da79a d015f88 e8da79a d015f88 e8da79a d015f88 e8da79a d015f88 e8da79a d015f88 e8da79a d015f88 e8da79a |
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 |
import os
from crews import get_financial_trading_crew
def invoke(openai_api_key, serper_api_key, stock_selection, initial_capital, risk_tolerance, trading_strategy_preference, news_impact_consideration):
if (openai_api_key == ""):
raise gr.Error("OpenAI API Key is required.")
if (serp_api_key == ""):
raise gr.Error("SERPER API Key is required.")
if (stock_selection == ""):
raise gr.Error("Stock Ticker is required.")
if (initial_capital == ""):
raise gr.Error("Initial Capital is required.")
if (risk_tolerance == ""):
raise gr.Error("Risk Tolerance is required.")
if (trading_strategy_preference == ""):
raise gr.Error("Trading Strategy Preference is required.")
if (news_impact_consideration == ""):
raise gr.Error("News Impact Consideration is required.")
os.environ["OPENAI_API_KEY"] = openai_api_key
os.environ["SERPER_API_KEY"] = serper_api_key
financial_trading_inputs = {
'stock_selection': stock_selection,
'initial_capital': initial_capital,
'risk_tolerance': risk_tolerance,
'trading_strategy_preference': trading_strategy_preference,
'news_impact_consideration': news_impact_consideration
}
return financial_trading_crew.kickoff(inputs=financial_trading_inputs)
description = """<a href='https://www.gradio.app/'>Gradio</a> UI using the <a href='https://openai.com/'>OpenAI</a> SDK
with <a href='https://openai.com/research/gpt-4'>gpt-4</a> model."""
gr.close_all()
demo = gr.Interface(fn = invoke,
inputs = [gr.Textbox(label = "OpenAI API Key", type = "password", lines = 1),
gr.Textbox(label = "SERPER API Key", type = "password", lines = 1),
gr.Textbox(label = "Stock Ticker", value="SAN", lines = 1),
gr.Textbox(label = "Initial Capital", value=1000, lines = 1),
gr.Textbox(label = "Risk Tolerance", value="Medium", lines = 1),
gr.Textbox(label = "Trading Strategy Preference", value="Day Trading", lines = 1),
gr.Textbox(label = "News Impact Consideration", value=True, lines = 1)],
outputs = [gr.Textbox(label = "Output", lines = 1)],
title = "Agentic RAG: Financial Analysis",
description = description)
demo.launch() |