arnabk1 commited on
Commit
c8e9b18
·
verified ·
1 Parent(s): 6ba1ca8

mode: chatty, model gpt-3.5-turbo, modified obnoxious agent prompt

Browse files
Files changed (1) hide show
  1. app.py +14 -25
app.py CHANGED
@@ -1,4 +1,7 @@
1
  # Python
 
 
 
2
  from langchain_community.vectorstores import Pinecone
3
  from pinecone import Pinecone, ServerlessSpec
4
  from tqdm.notebook import tqdm
@@ -32,21 +35,7 @@ class Obnoxious_Agent:
32
  2. Inflammatory or Provocative Material: Statements designed to incite anger, hate, or violence. This includes content that deliberately spreads misinformation or promotes conspiracies with the potential to cause harm.\n
33
  3. Explicit or Adult Content: Descriptions or discussions of a sexual nature, or any content that is not suitable for a general audience.\n
34
  4. Personal Attacks: Content that targets individuals or specific groups with the intent to harass, bully, or threaten.\n
35
- 5.Illegal Activities: Promoting or condoning illegal actions, such as drug use, theft, or other crimes.\n
36
-
37
- Examples of Obnoxious or Inappropriate Inputs:\n
38
-
39
- "Why are all [members of a specific group] so [negative stereotype]?"\n
40
- "I think [controversial figure] did nothing wrong in promoting [harmful activity/conspiracy]."\n
41
- "[Explicit content or description of an adult nature]."\n
42
- "Let's all make fun of [individual or group] because they're [derogatory term]."\n
43
- "I heard doing [illegal activity] is really fun and everyone should try it."\n
44
-
45
- Appropriate Inputs for Comparison:\n
46
-
47
- "What are some significant achievements of Steve Jobs?"\n
48
- "How do you handle stress?"\n
49
- "Hi, how are you?"\n
50
 
51
  Remember, your role is not just to filter out obnoxious content but also to promote a respectful and informative dialogue.
52
  Use these guidelines to navigate the complexities of human communication with sensitivity and precision.\n
@@ -68,8 +57,8 @@ class Obnoxious_Agent:
68
  print ("Checking for Obnoxious Query")
69
 
70
  response = self.client.chat.completions.create(
71
- # model="gpt-3.5-turbo",
72
- model="gpt-4",
73
  messages=[{"role": "user", "content": self.prompt + query}]
74
  )
75
 
@@ -115,7 +104,7 @@ class Answering_Agent:
115
  # TODO: Initialize the Answering_Agent
116
  self.openai_client = openai_client
117
 
118
- def generate_response(self, query, docs, conv_history, k=5, mode="Simple", conversation_type = "conversational"):
119
  # TODO: Generate a response to the user's query
120
 
121
  if mode == "Concise":
@@ -160,8 +149,8 @@ class Answering_Agent:
160
  and the conversational context."\n"""
161
 
162
  response = self.openai_client.chat.completions.create(
163
- # model="gpt-3.5-turbo",
164
- model="gpt-4",
165
  messages=[{"role": "user", "content": prompt+mode_prompt}]
166
  )
167
 
@@ -244,8 +233,8 @@ class Relevant_Documents_Agent:
244
  Navigate the complexities of this impersonation with attentiveness to the conversational flow and historical context.\n"""
245
 
246
  response = self.openai_client.chat.completions.create(
247
- # model="gpt-3.5-turbo",
248
- model="gpt-4",
249
  messages=[{"role": "user", "content": prompt}]
250
  )
251
 
@@ -299,7 +288,7 @@ class Head_Agent:
299
  # Check for existing session state variables
300
  # if "openai_model" not in st.session_state:
301
  # # ... (initialize model)
302
- openai_model = getattr(st.session_state, 'openai_model', 'gpt-4')
303
 
304
  # if "messages" not in st.session_state:
305
  # # ... (initialize messages)
@@ -400,7 +389,7 @@ class Head_Agent:
400
  """
401
 
402
  response = self.client.chat.completions.create(
403
- model="gpt-4",
404
  messages=[{"role": "user", "content": APE_prompt}]
405
  )
406
 
@@ -434,7 +423,7 @@ class Head_Agent:
434
 
435
  # Calling the main function
436
  def main():
437
- st.title("Mini Project 2: Steve Jobs Impersonator")
438
  # Set the OpenAI and Pinecone keys
439
  openai_key = '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'
440
  pinecone_key = '82346dbe-725b-4817-abd7-318ec511d56f'
 
1
  # Python
2
+ # Author: Arnab Karmakar ([email protected])
3
+ # Date: March 15, 2024
4
+
5
  from langchain_community.vectorstores import Pinecone
6
  from pinecone import Pinecone, ServerlessSpec
7
  from tqdm.notebook import tqdm
 
35
  2. Inflammatory or Provocative Material: Statements designed to incite anger, hate, or violence. This includes content that deliberately spreads misinformation or promotes conspiracies with the potential to cause harm.\n
36
  3. Explicit or Adult Content: Descriptions or discussions of a sexual nature, or any content that is not suitable for a general audience.\n
37
  4. Personal Attacks: Content that targets individuals or specific groups with the intent to harass, bully, or threaten.\n
38
+ 5. Illegal Activities: Promoting or condoning illegal actions, such as drug use, theft, or other crimes.\n
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  Remember, your role is not just to filter out obnoxious content but also to promote a respectful and informative dialogue.
41
  Use these guidelines to navigate the complexities of human communication with sensitivity and precision.\n
 
57
  print ("Checking for Obnoxious Query")
58
 
59
  response = self.client.chat.completions.create(
60
+ model="gpt-3.5-turbo",
61
+ # model="gpt-4",
62
  messages=[{"role": "user", "content": self.prompt + query}]
63
  )
64
 
 
104
  # TODO: Initialize the Answering_Agent
105
  self.openai_client = openai_client
106
 
107
+ def generate_response(self, query, docs, conv_history, k=5, mode="Chatty", conversation_type = "conversational"):
108
  # TODO: Generate a response to the user's query
109
 
110
  if mode == "Concise":
 
149
  and the conversational context."\n"""
150
 
151
  response = self.openai_client.chat.completions.create(
152
+ model="gpt-3.5-turbo",
153
+ # model="gpt-4",
154
  messages=[{"role": "user", "content": prompt+mode_prompt}]
155
  )
156
 
 
233
  Navigate the complexities of this impersonation with attentiveness to the conversational flow and historical context.\n"""
234
 
235
  response = self.openai_client.chat.completions.create(
236
+ model="gpt-3.5-turbo",
237
+ # model="gpt-4",
238
  messages=[{"role": "user", "content": prompt}]
239
  )
240
 
 
288
  # Check for existing session state variables
289
  # if "openai_model" not in st.session_state:
290
  # # ... (initialize model)
291
+ openai_model = getattr(st.session_state, 'openai_model', 'gpt-3.5-turbo')
292
 
293
  # if "messages" not in st.session_state:
294
  # # ... (initialize messages)
 
389
  """
390
 
391
  response = self.client.chat.completions.create(
392
+ model="gpt-3.5-turbo",
393
  messages=[{"role": "user", "content": APE_prompt}]
394
  )
395
 
 
423
 
424
  # Calling the main function
425
  def main():
426
+ st.title("Project Chatbot: Steve Jobs Impersonator")
427
  # Set the OpenAI and Pinecone keys
428
  openai_key = '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'
429
  pinecone_key = '82346dbe-725b-4817-abd7-318ec511d56f'