Vageesh1 commited on
Commit
298130b
·
1 Parent(s): a3ac02f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -18
app.py CHANGED
@@ -12,8 +12,6 @@ from langchain import HuggingFaceHub, LLMChain, PromptTemplate
12
  from langchain.memory import ConversationBufferWindowMemory
13
  from langchain.chains import ConversationalRetrievalChain
14
 
15
- os.environ["OPENAI_API_KEY"] ='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'
16
-
17
  trait_content_df=pd.read_csv('AI Personality Chart trait_content.csv')
18
  trait_content_df=trait_content_df.drop(0,axis=0)
19
  trait_content_df.rename(columns={'Column 1':'Question','Column 2':'Options','Column 3':'Traits','Column 4':'Content'},inplace=True)
@@ -21,7 +19,7 @@ trait_content_df['Title'].fillna(method='ffill',inplace=True)
21
  trait_content_df['Question'].fillna(method='ffill',inplace=True)
22
 
23
  template = """
24
- Imagine you are a person that is looking for making a cool dating app bio. Craft distinctive responses for each user based on traits extracted and refer from the content provided for each trait, even if the prompts are similar.Make a single Bio for all traits at once, no need to make different for each trait. Respond it in 2nd person view. Avoid using the same sentences for different users while keeping the response within 100 words.
25
  {history}
26
  Me:{human_input}
27
  Jack:
@@ -65,12 +63,6 @@ trait_content_df_org=pd.read_csv('AI Personality Chart trait_content.csv')
65
  trait_content_df_org=trait_content_df_org.drop(0,axis=0)
66
  trait_content_df_org.rename(columns={'Column 1':'Question','Column 2':'Options','Column 3':'Traits','Column 4':'Content'},inplace=True)
67
 
68
- # Import the second CSV file
69
- traits_description_df = pd.read_csv('Traits Description - Sheet1.csv')
70
-
71
- # Extract unique values from the "Traits" column of trait_content_df_org
72
- unique_traits = trait_content_df_org['Traits'].unique()
73
-
74
 
75
  def ui():
76
  # Initialize a dictionary to store responses
@@ -105,11 +97,11 @@ def ui():
105
  st.write(question)
106
  st.write(selected_option)
107
 
108
- # Extract traits from the selected options
109
  selected_traits = [responses[question] for question in responses]
110
  options_list = []
111
  traits_list = []
112
- # content_list = []
113
 
114
  for trait_str in selected_traits:
115
  matching_rows = trait_content_df_org[trait_content_df_org["Options"] == trait_str]
@@ -117,24 +109,25 @@ def ui():
117
  if not matching_rows.empty:
118
  options_list.append(matching_rows["Options"].values[0])
119
  traits_list.append(matching_rows["Traits"].values[0])
 
120
 
121
- # Get unique traits from the selected options
122
- unique_traits = list(set(traits_list))
123
-
124
- # Create a content list as a formatted string
125
- formatted_content_list = ",".join([f"'{trait.lower()}'" for trait in unique_traits])
126
 
127
  # Display user input field
128
  name_input = st.text_input("Enter your name:")
129
 
130
  # Add a submit button
131
  if st.button("Submit"):
132
- # Generate a chatbot response using the formatted content list as part of the prompt
133
- prompt = f"The following are Traits {formatted_content_list}"
134
  bio = conversational_chat(prompt, name_input)
135
  st.write(bio)
136
 
137
 
138
 
 
 
 
 
139
  if __name__=='__main__':
140
  ui()
 
 
12
  from langchain.memory import ConversationBufferWindowMemory
13
  from langchain.chains import ConversationalRetrievalChain
14
 
 
 
15
  trait_content_df=pd.read_csv('AI Personality Chart trait_content.csv')
16
  trait_content_df=trait_content_df.drop(0,axis=0)
17
  trait_content_df.rename(columns={'Column 1':'Question','Column 2':'Options','Column 3':'Traits','Column 4':'Content'},inplace=True)
 
19
  trait_content_df['Question'].fillna(method='ffill',inplace=True)
20
 
21
  template = """
22
+ Imagine you are a person that is looking for making a cool dating app bio. Craft distinctive responses for each user based on traits extracted and refer from the content provided for each trait, even if the prompts are similar.Make a single Bio for all traits at once, no need to make different for each trait. Respond it in 2nd person view. Avoid using the same sentences for different users while keeping the response within 100 words.
23
  {history}
24
  Me:{human_input}
25
  Jack:
 
63
  trait_content_df_org=trait_content_df_org.drop(0,axis=0)
64
  trait_content_df_org.rename(columns={'Column 1':'Question','Column 2':'Options','Column 3':'Traits','Column 4':'Content'},inplace=True)
65
 
 
 
 
 
 
 
66
 
67
  def ui():
68
  # Initialize a dictionary to store responses
 
97
  st.write(question)
98
  st.write(selected_option)
99
 
100
+ # Generate a prompt based on selected options
101
  selected_traits = [responses[question] for question in responses]
102
  options_list = []
103
  traits_list = []
104
+ content_list = []
105
 
106
  for trait_str in selected_traits:
107
  matching_rows = trait_content_df_org[trait_content_df_org["Options"] == trait_str]
 
109
  if not matching_rows.empty:
110
  options_list.append(matching_rows["Options"].values[0])
111
  traits_list.append(matching_rows["Traits"].values[0])
112
+ content_list.append(matching_rows["Content"].values[0])
113
 
114
+ prompt = f"The following are Traits {', '.join(traits_list)}, and the content for the options is {', '.join(content_list)}"
 
 
 
 
115
 
116
  # Display user input field
117
  name_input = st.text_input("Enter your name:")
118
 
119
  # Add a submit button
120
  if st.button("Submit"):
121
+ # Generate a chatbot response
 
122
  bio = conversational_chat(prompt, name_input)
123
  st.write(bio)
124
 
125
 
126
 
127
+
128
+
129
+
130
+
131
  if __name__=='__main__':
132
  ui()
133
+