Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
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() => {
|