File size: 1,941 Bytes
d72be0f
f2b0df2
 
 
 
d72be0f
d43f0b6
f2b0df2
 
 
6d37db9
d43f0b6
 
 
b8d8ef1
d43f0b6
6d37db9
d43f0b6
 
 
 
 
 
 
6d37db9
d43f0b6
 
 
b8d8ef1
d43f0b6
 
6d37db9
d43f0b6
 
 
 
 
 
 
6d37db9
d43f0b6
6d37db9
d72be0f
 
 
165f08c
d72be0f
 
 
6d37db9
 
 
 
d72be0f
 
 
 
 
6d37db9
d72be0f
 
 
cb334de
 
c8739b3
cb334de
 
c8739b3
d72be0f
 
 
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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()