Eriberto commited on
Commit
5f15ad1
1 Parent(s): 8764ad0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -10
app.py CHANGED
@@ -7,17 +7,22 @@ import random
7
  openai.api_key = os.environ.get('SessionToken')
8
  logger.info(f"session_token_: {openai.api_key}")
9
 
 
 
 
 
10
  def get_response_from_chatgpt(text):
11
- try:
12
- response_api = openai.Completion.create(engine='text-davinci-003', prompt=str(text), max_tokens=100)
13
- response_str = response["choices"][0]["text"].replace("\n", "")
14
- response_str = response_str.split(user_name + ": ", 1)[0].split(bot_name + ": ", 1)[0]
15
- print("RESPONSE STRING", response_str)
16
- response = response_str
17
- logger.info(f"Response: [{response_api}]")
18
- logger.info(f"conversation_id_: [{response}]")
19
- except:
20
- response = "I'm so tired. Let me lie down for a few days."
 
21
  return response
22
 
23
  start_work = """async() => {
 
7
  openai.api_key = os.environ.get('SessionToken')
8
  logger.info(f"session_token_: {openai.api_key}")
9
 
10
+ conversation = ""
11
+ user_name = "MH"
12
+ bot_name = "bbDemo"
13
+
14
  def get_response_from_chatgpt(text):
15
+ #try:
16
+ response_api = openai.Completion.create(engine='text-davinci-003', prompt=str(text), max_tokens=100)
17
+ response_str = response_api["choices"][0]["text"].replace("\n", "")
18
+ response_str = response_str.split(user_name + ": ", 1)[0].split(bot_name + ": ", 1)[0]
19
+ print("RESPONSE response_api", response_api)
20
+ print("RESPONSE response_str ", response_str)
21
+ response = response_str
22
+ logger.info(f"Response: [{response_api}]")
23
+ logger.info(f"conversation_id_: [{response}]")
24
+ #except:
25
+ #response = "I'm so tired. Let me lie down for a few days."
26
  return response
27
 
28
  start_work = """async() => {