Bullet500 commited on
Commit
27bfd7c
·
verified ·
1 Parent(s): d531e74

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -0
app.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain.chains.llm import LLMChain
2
+ from langchain.chains.sequential import SequentialChain
3
+ from langchain_groq import ChatGroq
4
+ from langchain.prompts import PromptTemplate
5
+ import streamlit as st
6
+
7
+ # Streamlit Title
8
+ st.title('AI TRADER')
9
+
10
+ # Input for trading details
11
+ traders_info = st.text_input('Enter the Trading Details from Market Research and Technical Analysis')
12
+ submit = st.button('SUBMIT')
13
+
14
+ # LLM Model Initialization
15
+ LLM_model = ChatGroq(
16
+ temperature=0.6,
17
+ groq_api_key='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'
18
+ )
19
+
20
+ # Prompt Templates and Chains
21
+ prompt1 = PromptTemplate(
22
+ input_variables=['input'],
23
+ template='Based on {input}, which share price will give the highest returns in future options? Summarize in 30 words.'
24
+ )
25
+ chain1 = LLMChain(llm=LLM_model, prompt=prompt1, output_key='shares')
26
+
27
+ prompt2 = PromptTemplate(
28
+ input_variables=['shares'],
29
+ template='What is the current price of {shares}, and what will be the predicted price after five minutes?'
30
+ )
31
+ chain2 = LLMChain(llm=LLM_model, prompt=prompt2, output_key='price_prediction')
32
+
33
+ prompt3 = PromptTemplate(
34
+ input_variables=['shares'],
35
+ template='Name five shares with positive daily growth trends based on the analysis of {shares}.'
36
+ )
37
+ chain3 = LLMChain(llm=LLM_model, prompt=prompt3, output_key='positive_growth_shares')
38
+
39
+ # Sequential Chain
40
+ parent_chain = SequentialChain(
41
+ chains=[chain1, chain2, chain3],
42
+ input_variables=['input'],
43
+ output_variables=['shares', 'price_prediction', 'positive_growth_shares']
44
+ )
45
+
46
+ # Streamlit Logic
47
+ if submit:
48
+ if traders_info.strip():
49
+ result = parent_chain({'input': traders_info})
50
+ st.write('**Suggested Shares:**', result['shares'])
51
+ st.write('**Price Prediction:**', result['price_prediction'])
52
+ st.write('**Positive Growth Shares:**', result['positive_growth_shares'])
53
+ else:
54
+ st.warning('Please provide trading details to proceed.')
55
+