|
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 |
|
|
|
|
|
st.title('AI TRADER') |
|
|
|
|
|
traders_info = st.text_input('Enter the Trading Details from Market Research and Technical Analysis') |
|
submit = st.button('SUBMIT') |
|
|
|
|
|
LLM_model = ChatGroq( |
|
temperature=0.6, |
|
groq_api_key='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' |
|
) |
|
|
|
|
|
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') |
|
|
|
|
|
parent_chain = SequentialChain( |
|
chains=[chain1, chain2, chain3], |
|
input_variables=['input'], |
|
output_variables=['shares', 'price_prediction', 'positive_growth_shares'] |
|
) |
|
|
|
|
|
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.') |
|
|
|
|