File size: 1,937 Bytes
27bfd7c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
52
53
54
55
56
from langchain.chains.llm import LLMChain
from langchain.chains.sequential import SequentialChain
from langchain_groq import ChatGroq
from langchain.prompts import PromptTemplate
import streamlit as st

# Streamlit Title
st.title('AI TRADER')

# Input for trading details
traders_info = st.text_input('Enter the Trading Details from Market Research and Technical Analysis')
submit = st.button('SUBMIT')

# LLM Model Initialization
LLM_model = ChatGroq(
    temperature=0.6,
    groq_api_key='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'
)

# Prompt Templates and Chains
prompt1 = PromptTemplate(
    input_variables=['input'],
    template='Based on {input}, which share price will give the highest returns in future options? Summarize in 30 words.'
)
chain1 = LLMChain(llm=LLM_model, prompt=prompt1, output_key='shares')

prompt2 = PromptTemplate(
    input_variables=['shares'],
    template='What is the current price of {shares}, and what will be the predicted price after five minutes?'
)
chain2 = LLMChain(llm=LLM_model, prompt=prompt2, output_key='price_prediction')

prompt3 = PromptTemplate(
    input_variables=['shares'],
    template='Name five shares with positive daily growth trends based on the analysis of {shares}.'
)
chain3 = LLMChain(llm=LLM_model, prompt=prompt3, output_key='positive_growth_shares')

# Sequential Chain
parent_chain = SequentialChain(
    chains=[chain1, chain2, chain3],
    input_variables=['input'],
    output_variables=['shares', 'price_prediction', 'positive_growth_shares']
)

# Streamlit Logic
if submit:
    if traders_info.strip():
        result = parent_chain({'input': traders_info})
        st.write('**Suggested Shares:**', result['shares'])
        st.write('**Price Prediction:**', result['price_prediction'])
        st.write('**Positive Growth Shares:**', result['positive_growth_shares'])
    else:
        st.warning('Please provide trading details to proceed.')