AjithKSenthil commited on
Commit
558a24d
·
verified ·
1 Parent(s): 4218952

Update chatbot.py

Browse files
Files changed (1) hide show
  1. chatbot.py +4 -4
chatbot.py CHANGED
@@ -2,12 +2,12 @@ import openai
2
  import gradio as gr
3
  import os
4
 
5
- # Set OpenAI API key from environment variable
6
- openai.api_key = os.getenv("OPENAI_API_KEY")
7
 
8
  # Initial system messages for the chatbot
9
  initial_messages = [
10
- {"role": "system", "content": "You are an attachment and close relationship research surveyor"},
11
  {"role": "user", "content": """ask me each question from this questionnaire and rewrite it as an open ended question and wait for each response. Empathize with me and regularly ask for clarification why I answered with a certain response. Here is the questionnaire:
12
  Can you describe your relationship with your mother or a mother-like figure in your life?
13
  Do you usually discuss your problems and concerns with your mother or a mother-like figure?
@@ -20,7 +20,7 @@ def chatbot(input):
20
 
21
  if input:
22
  chatbot.messages.append({"role": "user", "content": input})
23
- response = openai.ChatCompletion.create(
24
  model="gpt-3.5-turbo",
25
  messages=chatbot.messages
26
  )
 
2
  import gradio as gr
3
  import os
4
 
5
+ # Initialize OpenAI client
6
+ client = openai.OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
7
 
8
  # Initial system messages for the chatbot
9
  initial_messages = [
10
+ {"role": "system", "content": "You are an attachment and close relationship research surveyor"},
11
  {"role": "user", "content": """ask me each question from this questionnaire and rewrite it as an open ended question and wait for each response. Empathize with me and regularly ask for clarification why I answered with a certain response. Here is the questionnaire:
12
  Can you describe your relationship with your mother or a mother-like figure in your life?
13
  Do you usually discuss your problems and concerns with your mother or a mother-like figure?
 
20
 
21
  if input:
22
  chatbot.messages.append({"role": "user", "content": input})
23
+ response = client.chat.completions.create(
24
  model="gpt-3.5-turbo",
25
  messages=chatbot.messages
26
  )