Spaces:
Sleeping
Sleeping
File size: 906 Bytes
6fa996a fc49341 6fa996a fc49341 6fa996a 2970e1e |
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 |
# app.py
import gradio as gr
from core.stock_analysis import analyze_stock
from core.market_stock_sentiment import get_market_stock_sentiment
from langchain_google_genai import ChatGoogleGenerativeAI
import os
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
llm = ChatGoogleGenerativeAI(model="gemini-2.5-pro", google_api_key=GOOGLE_API_KEY)
def analyze_api(ticker):
ticker_val = ticker.strip().upper()
if ticker_val == "ALL_STOCKS":
return get_market_stock_sentiment(llm)
else:
return analyze_stock(ticker_val, llm)
demo = gr.Interface(
fn=analyze_api,
inputs=gr.Textbox(label="Enter NSE Ticker (e.g., RELIANCE)"),
outputs="json",
title="π Stock Analysis API (NSE)",
description="Get analysis and insights for Indian stocks using Google Gemini + LangChain. Returns structured JSON."
)
if __name__ == "__main__":
demo.queue(api_open=True).launch()
|