Spaces:
Runtime error
Runtime error
Commit
·
6d37db9
1
Parent(s):
4002b67
Update app.py
Browse files
app.py
CHANGED
@@ -8,15 +8,15 @@ from langchain.chains import LLMChain
|
|
8 |
|
9 |
api_key = os.environ['openai_api_key']
|
10 |
|
11 |
-
def get_insurance_heading(data):
|
12 |
|
13 |
llm = OpenAI(temperature=0,openai_api_key=api_key)
|
14 |
|
15 |
-
prompt_template = """this is article content and my user is insurance industry now give me user specific or we can personalize heading hook line for article, which can include something related to the industry with respect to the content and need only article heading nothing else
|
16 |
|
17 |
-
article content: {text} """
|
18 |
PROMPT = PromptTemplate(
|
19 |
-
template=
|
20 |
)
|
21 |
chain = LLMChain(llm=llm, prompt=PROMPT)
|
22 |
resp = chain.run(text=data)
|
@@ -24,15 +24,15 @@ def get_insurance_heading(data):
|
|
24 |
return resp
|
25 |
|
26 |
|
27 |
-
def get_sports_heading(data):
|
28 |
|
29 |
llm = OpenAI(temperature=0,openai_api_key=api_key)
|
30 |
|
31 |
-
prompt_template = """this is article content and my user is sports industry now give me user specific or we can personalize heading hook line for article, which can include something related to the industry with respect to the content and need only article heading nothing else
|
32 |
|
33 |
-
article content: {text} """
|
34 |
PROMPT = PromptTemplate(
|
35 |
-
template=
|
36 |
)
|
37 |
chain = LLMChain(llm=llm, prompt=PROMPT)
|
38 |
resp = chain.run(text=data)
|
@@ -40,9 +40,9 @@ def get_sports_heading(data):
|
|
40 |
return resp
|
41 |
|
42 |
|
43 |
-
def process_article_content(content):
|
44 |
|
45 |
-
return get_insurance_heading(content), get_sports_heading(content)
|
46 |
|
47 |
# Streamlit app
|
48 |
def main():
|
@@ -50,12 +50,16 @@ def main():
|
|
50 |
|
51 |
# Input field for article content
|
52 |
article_content = st.text_area("Enter Article Content:", "")
|
|
|
|
|
|
|
|
|
53 |
|
54 |
# Process button
|
55 |
if st.button("Process"):
|
56 |
# Process the article content
|
57 |
if article_content:
|
58 |
-
insurance_user, sports_user = process_article_content(article_content)
|
59 |
|
60 |
# Display the output
|
61 |
st.subheader("Processed Output:")
|
|
|
8 |
|
9 |
api_key = os.environ['openai_api_key']
|
10 |
|
11 |
+
def get_insurance_heading(data,insurance_prompt):
|
12 |
|
13 |
llm = OpenAI(temperature=0,openai_api_key=api_key)
|
14 |
|
15 |
+
# prompt_template = """this is article content and my user is insurance industry now give me user specific or we can personalize heading hook line for article, which can include something related to the industry with respect to the content and need only article heading nothing else
|
16 |
|
17 |
+
# article content: {text} """
|
18 |
PROMPT = PromptTemplate(
|
19 |
+
template=insurance_prompt, input_variables=["text"]
|
20 |
)
|
21 |
chain = LLMChain(llm=llm, prompt=PROMPT)
|
22 |
resp = chain.run(text=data)
|
|
|
24 |
return resp
|
25 |
|
26 |
|
27 |
+
def get_sports_heading(data,sports_prompt):
|
28 |
|
29 |
llm = OpenAI(temperature=0,openai_api_key=api_key)
|
30 |
|
31 |
+
# prompt_template = """this is article content and my user is sports industry now give me user specific or we can personalize heading hook line for article, which can include something related to the industry with respect to the content and need only article heading nothing else
|
32 |
|
33 |
+
# article content: {text} """
|
34 |
PROMPT = PromptTemplate(
|
35 |
+
template=sports_prompt, input_variables=["text"]
|
36 |
)
|
37 |
chain = LLMChain(llm=llm, prompt=PROMPT)
|
38 |
resp = chain.run(text=data)
|
|
|
40 |
return resp
|
41 |
|
42 |
|
43 |
+
def process_article_content(content,insurance_prompt,sports_prompt):
|
44 |
|
45 |
+
return get_insurance_heading(content,insurance_prompt), get_sports_heading(content,sports_prompt)
|
46 |
|
47 |
# Streamlit app
|
48 |
def main():
|
|
|
50 |
|
51 |
# Input field for article content
|
52 |
article_content = st.text_area("Enter Article Content:", "")
|
53 |
+
insurance_prompt = st.text_area("insurance prompt", "")
|
54 |
+
sports_prompt = st.text_area("sports prompt", "")
|
55 |
+
|
56 |
+
|
57 |
|
58 |
# Process button
|
59 |
if st.button("Process"):
|
60 |
# Process the article content
|
61 |
if article_content:
|
62 |
+
insurance_user, sports_user = process_article_content(article_content,insurance_prompt,sports_prompt)
|
63 |
|
64 |
# Display the output
|
65 |
st.subheader("Processed Output:")
|