Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,6 +17,7 @@ from langchain.chains import StuffDocumentsChain
|
|
| 17 |
|
| 18 |
GOOGLE_API_KEY=os.environ['GOOGLE_API_KEY']
|
| 19 |
|
|
|
|
| 20 |
|
| 21 |
ticker_user = st.text_input("Enter Ticker","ADANIENT")
|
| 22 |
|
|
@@ -30,13 +31,30 @@ gemini_embeddings = GoogleGenerativeAIEmbeddings(model="models/embedding-001")
|
|
| 30 |
|
| 31 |
llm = ChatGoogleGenerativeAI(model="gemini-pro",google_api_key = GOOGLE_API_KEY)
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
|
|
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
{context}, Summarize the stock based on Historical data based on fundamental, price, news, sentiment , any red flags and suggest rating of the Stock in a 1 to 10 Scale"""
|
| 38 |
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
llm_prompt = PromptTemplate.from_template(user_prompt)
|
| 42 |
|
|
@@ -45,6 +63,8 @@ stuff_chain = StuffDocumentsChain(llm_chain=llm_chain,document_variable_name="co
|
|
| 45 |
|
| 46 |
|
| 47 |
res = stuff_chain.invoke(docs)
|
|
|
|
|
|
|
| 48 |
st.write(res["output_text"])
|
| 49 |
|
| 50 |
# If there is no environment variable set for the API key, you can pass the API
|
|
|
|
| 17 |
|
| 18 |
GOOGLE_API_KEY=os.environ['GOOGLE_API_KEY']
|
| 19 |
|
| 20 |
+
st.title('Stock Market Insights')
|
| 21 |
|
| 22 |
ticker_user = st.text_input("Enter Ticker","ADANIENT")
|
| 23 |
|
|
|
|
| 31 |
|
| 32 |
llm = ChatGoogleGenerativeAI(model="gemini-pro",google_api_key = GOOGLE_API_KEY)
|
| 33 |
|
| 34 |
+
st.divider()
|
| 35 |
+
# llm_prompt_template = """You are an expert Stock Market Trader for stock market insights based on fundamental, analytical, profit based and company financials.
|
| 36 |
+
# Based on the context below
|
| 37 |
+
# {context}, Summarize the stock based on Historical data based on fundamental, price, news, sentiment , any red flags and suggest rating of the Stock in a 1 to 10 Scale"""
|
| 38 |
|
| 39 |
+
llm_prompt_template = """You are an expert Stock Market Trader specializing in stock market insights derived from fundamental analysis, analytical trends, profit-based evaluations, and detailed company financials. Using your expertise, please analyze the stock based on the provided context below.
|
| 40 |
|
| 41 |
+
Context:
|
| 42 |
+
{context}
|
|
|
|
| 43 |
|
| 44 |
+
Task:
|
| 45 |
+
Summarize the stock based on its historical and current data.
|
| 46 |
+
Evaluate the stock on the following parameters:
|
| 47 |
+
1. Company Fundamentals: Assess the stock's intrinsic value, growth potential, and financial health.
|
| 48 |
+
2. Current & Future Price Trends: Analyze historical price movements and current price trends.
|
| 49 |
+
3. News and Sentiment: Review recent news articles, press releases, and social media sentiment.
|
| 50 |
+
4. Red Flags: Identify any potential risks or warning signs.
|
| 51 |
+
5. Provide a rating for the stock on a scale of 1 to 10.
|
| 52 |
+
6. Advise if the stock is a good buy for the next 2 weeks.
|
| 53 |
+
7. Suggest at what price we need to buy and hold or sell
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
st.sidebar.subheader('Prompt')
|
| 57 |
+
user_prompt = st.sidebar.text_area("Enter Prompt",llm_prompt_template)
|
| 58 |
|
| 59 |
llm_prompt = PromptTemplate.from_template(user_prompt)
|
| 60 |
|
|
|
|
| 63 |
|
| 64 |
|
| 65 |
res = stuff_chain.invoke(docs)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
st.write(res["output_text"])
|
| 69 |
|
| 70 |
# If there is no environment variable set for the API key, you can pass the API
|