pranked03 commited on
Commit
7ad19af
1 Parent(s): 08981b2
Files changed (3) hide show
  1. app.py +40 -0
  2. new.py +25 -0
  3. requirements.txt +65 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from new import chat_with_chatseo
3
+ import pandas as pd
4
+
5
+ st.set_page_config(layout="wide")
6
+
7
+ i, j = st.columns(2)
8
+ #set title
9
+ with i:
10
+ st.title("Chat with ChatSEO")
11
+
12
+
13
+ #create 3 input boxes for the 3 input variables
14
+ issue = st.text_input("Issue")
15
+ description = st.text_input("Description")
16
+ url = st.text_input("URL")
17
+
18
+ #create button and on press, run the chain
19
+ if st.button("Run"):
20
+ #run the chain
21
+ output = chat_with_chatseo(issue, description, url).content
22
+ #display the output
23
+ st.write(output)
24
+
25
+ with j:
26
+
27
+ st.write("## Upload a csv file")
28
+
29
+ # Upload a csv file using streamlit and show the data
30
+ uploaded_file = st.file_uploader("Choose a CSV file")
31
+ if uploaded_file is not None:
32
+ df = pd.read_csv(uploaded_file)
33
+ result_df = df[df["Issue Priority"] == "High"].drop(["URLs", "% of Total", "How To Fix"], axis=1)
34
+ st.write(result_df)
35
+ for index, row in result_df.iterrows():
36
+ with st.expander(row["Issue Name"]):
37
+ st.write(row["Description"])
38
+ if st.button("Fix Issue", key=index):
39
+ output = chat_with_chatseo(row["Issue Name"], row["Description"], "https://www.upthrust.io").content
40
+ st.write(output)
new.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain.chat_models import ChatOpenAI
2
+ import streamlit as st
3
+ def chatseo():
4
+
5
+ from langchain import PromptTemplate
6
+ from langchain.prompts.chat import (
7
+ ChatPromptTemplate,
8
+ SystemMessagePromptTemplate,
9
+ AIMessagePromptTemplate,
10
+ HumanMessagePromptTemplate,
11
+ )
12
+
13
+ template="You are an SEO Analyser.\nYou will be given an issue dealt with SEO, and its description.\nFor a given url, you need to create a 5 step plan to fix that issue.\nRemember to give examples as well for each step. Include some necessary code to fix that issue like ```some code```."
14
+ system_message_prompt = SystemMessagePromptTemplate.from_template(template)
15
+ human_template="Issue: {issue}\nDescription: {description}\nURL: {url}"
16
+ human_message_prompt = HumanMessagePromptTemplate.from_template(human_template)
17
+
18
+ chat_prompt = ChatPromptTemplate.from_messages([system_message_prompt, human_message_prompt])
19
+ return chat_prompt
20
+
21
+ # get a chat completion from the formatted messages
22
+ chat_prompt = chatseo()
23
+ def chat_with_chatseo(issue, description, url, chat_prompt = chat_prompt):
24
+ chat = ChatOpenAI(openai_api_key=st.secrets["openai_api_key"])
25
+ return chat(chat_prompt.format_prompt(issue=issue, description=description, url=url).to_messages())
requirements.txt ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ aiohttp==3.8.4
2
+ aiosignal==1.3.1
3
+ altair==5.0.1
4
+ async-timeout==4.0.2
5
+ attrs==23.1.0
6
+ blinker==1.6.2
7
+ cachetools==5.3.1
8
+ certifi==2023.5.7
9
+ charset-normalizer==3.1.0
10
+ click==8.1.3
11
+ dataclasses-json==0.5.8
12
+ decorator==5.1.1
13
+ frozenlist==1.3.3
14
+ gitdb==4.0.10
15
+ GitPython==3.1.31
16
+ idna==3.4
17
+ importlib-metadata==6.7.0
18
+ Jinja2==3.1.2
19
+ jsonschema==4.17.3
20
+ langchain==0.0.205
21
+ langchainplus-sdk==0.0.11
22
+ markdown-it-py==3.0.0
23
+ MarkupSafe==2.1.3
24
+ marshmallow==3.19.0
25
+ marshmallow-enum==1.5.1
26
+ mdurl==0.1.2
27
+ multidict==6.0.4
28
+ mypy-extensions==1.0.0
29
+ numexpr==2.8.4
30
+ numpy==1.25.0
31
+ openai==0.27.8
32
+ openapi-schema-pydantic==1.2.4
33
+ packaging==23.1
34
+ pandas==2.0.2
35
+ Pillow==9.5.0
36
+ protobuf==4.23.3
37
+ pyarrow==12.0.1
38
+ pydantic==1.10.9
39
+ pydeck==0.8.1b0
40
+ Pygments==2.15.1
41
+ Pympler==1.0.1
42
+ pyrsistent==0.19.3
43
+ python-dateutil==2.8.2
44
+ pytz==2023.3
45
+ pytz-deprecation-shim==0.1.0.post0
46
+ PyYAML==6.0
47
+ requests==2.31.0
48
+ rich==13.4.2
49
+ six==1.16.0
50
+ smmap==5.0.0
51
+ SQLAlchemy==2.0.16
52
+ streamlit==1.23.1
53
+ tenacity==8.2.2
54
+ toml==0.10.2
55
+ toolz==0.12.0
56
+ tornado==6.3.2
57
+ tqdm==4.65.0
58
+ typing-inspect==0.9.0
59
+ typing_extensions==4.6.3
60
+ tzdata==2023.3
61
+ tzlocal==4.3
62
+ urllib3==2.0.3
63
+ validators==0.20.0
64
+ yarl==1.9.2
65
+ zipp==3.15.0