import sys import json import os import requests from dotenv import load_dotenv import streamlit as st import plotly.graph_objects as go import plotly.express as px from openai import AzureOpenAI import pandas as pd import numpy as np from datetime import datetime, timedelta from dotted_dict import DottedDict from langchain_community.vectorstores import Chroma from langchain_openai import AzureChatOpenAI, AzureOpenAIEmbeddings from py.data_fetch import DataFetch from py.handle_files import * from py.db_storage import DBStorage from langchain.callbacks import get_openai_callback from PyPDF2 import PdfReader from langchain.text_splitter import RecursiveCharacterTextSplitter from langchain_community.vectorstores import FAISS from langchain.chains.question_answering import load_qa_chain from langchain.prompts import PromptTemplate import yfinance as yf class StockAdviserConfig: def __init__(self): load_dotenv() self.azure_config = { "base_url": os.getenv("AZURE_OPENAI_ENDPOINT"), "embedding_base_url": os.getenv("AZURE_OPENAI_EMBEDDING_ENDPOINT"), "model_deployment": os.getenv("AZURE_OPENAI_MODEL_DEPLOYMENT_NAME"), "model_name": os.getenv("AZURE_OPENAI_MODEL_NAME"), "embedding_deployment": os.getenv("AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME"), "embedding_name": os.getenv("AZURE_OPENAI_EMBEDDING_NAME"), "api-key": os.getenv("AZURE_OPENAI_API_KEY"), "api_version": os.getenv("AZURE_OPENAI_API_VERSION") } self.models = DottedDict() class StockAdviserUI: def __init__(self): st.set_page_config(page_title="GEN AI Stock Adviser by Karthikeyen", layout="wide", initial_sidebar_state="expanded") self._setup_css() self._setup_header() def _setup_css(self): st.markdown(""" """, unsafe_allow_html=True) def _setup_header(self): st.markdown("
This application provides investment managers with daily insights into social media and news sentiment surrounding specific stocks and companies. By analyzing posts and articles across major platforms such as Reddit, YouTube, Tumblr, Google News, Financial Times, Bloomberg, Reuters, and Wall Street Journal (WSJ), it detects shifts in public and media opinion that may impact stock performance.
Additionally, sources like Serper provide data from StockNews, Yahoo Finance, Insider Monkey, Investor's Business Daily, and others. Using advanced AI techniques, the application generates a sentiment report that serves as a leading indicator, helping managers make informed, timely adjustments to their positions. With daily updates and historical trend analysis, it empowers users to stay ahead in a fast-paced, sentiment-driven market.
The application also utilizes intelligent agent functions to determine the type of query input by the user. It assesses whether the query seeks stock statistics, sentiment-analyzed advice, both, or is unrelated, providing the most relevant response accordingly.
Developed by: Karthikeyen Packirisamy
© 2024 Karthikeyen
", unsafe_allow_html=True) if __name__ == "__main__": hugg = os.getenv("IS_HUGG") == "True" print(hugg) main(hugg)