health-day / app.py
deepakchawla-cb's picture
Update app.py
cb334de
raw
history blame
1.94 kB
import streamlit as st
import os
from langchain.llms import OpenAI
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
api_key = os.environ['openai_api_key']
def get_insurance_heading(data,insurance_prompt):
llm = OpenAI(temperature=0,openai_api_key=api_key)
prompt_template = "prompt: " + insurance_prompt + " and article content: {text} "
PROMPT = PromptTemplate(
template=insurance_prompt, input_variables=["text"]
)
chain = LLMChain(llm=llm, prompt=PROMPT)
resp = chain.run(text=data)
return resp
def get_sports_heading(data,sports_prompt):
llm = OpenAI(temperature=0,openai_api_key=api_key)
prompt_template = "prompt: " + sports_prompt + " and article content: {text} "
PROMPT = PromptTemplate(
template=sports_prompt, input_variables=["text"]
)
chain = LLMChain(llm=llm, prompt=PROMPT)
resp = chain.run(text=data)
return resp
def process_article_content(content,insurance_prompt,sports_prompt):
return get_insurance_heading(content,insurance_prompt), get_sports_heading(content,sports_prompt)
# Streamlit app
def main():
st.title("Health Day Demo")
# Input field for article content
article_content = st.text_area("Enter Article Content:", "")
insurance_prompt = st.text_area("insurance prompt", "")
sports_prompt = st.text_area("sports prompt", "")
# Process button
if st.button("Process"):
# Process the article content
if article_content:
insurance_user, sports_user = process_article_content(article_content,insurance_prompt,sports_prompt)
# Display the output
st.subheader("Processed Output:")
st.title("Insurance User")
st.write(f"{insurance_user}")
st.title("Sports User")
st.write(f"{sports_user}")
if __name__ == "__main__":
main()