Spaces:
Sleeping
Sleeping
새 수정
Browse files- chatbot_utils.py +0 -13
chatbot_utils.py
CHANGED
@@ -3,7 +3,6 @@ from openai import OpenAI
|
|
3 |
import json
|
4 |
from datetime import datetime
|
5 |
from scenario_handler import ScenarioHandler
|
6 |
-
import asyncio
|
7 |
|
8 |
client = OpenAI(api_key="sk-proj-3IEelWYK3Wl251k9qNriT3BlbkFJ9M7GpUGBijobUj1LETdu")
|
9 |
|
@@ -32,18 +31,6 @@ def chatbot_response(response, handler_type='offender', n=1):
|
|
32 |
choices = [choice.message.content for choice in api_response.choices]
|
33 |
return choices[0], choices
|
34 |
|
35 |
-
async def async_chatbot_response(response, handler_type='offender', n=1):
|
36 |
-
return chatbot_response(response, handler_type, n)
|
37 |
-
|
38 |
-
async def get_both_responses(user_input):
|
39 |
-
victim_task = asyncio.create_task(async_chatbot_response(user_input, 'victim', n=3))
|
40 |
-
offender_task = asyncio.create_task(async_chatbot_response(user_input, 'offender', n=1))
|
41 |
-
|
42 |
-
victim_response, victim_choices = await victim_task
|
43 |
-
offender_response, _ = await offender_task
|
44 |
-
|
45 |
-
return victim_response, victim_choices, offender_response
|
46 |
-
|
47 |
def save_history(history):
|
48 |
os.makedirs('logs', exist_ok=True)
|
49 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
|
|
3 |
import json
|
4 |
from datetime import datetime
|
5 |
from scenario_handler import ScenarioHandler
|
|
|
6 |
|
7 |
client = OpenAI(api_key="sk-proj-3IEelWYK3Wl251k9qNriT3BlbkFJ9M7GpUGBijobUj1LETdu")
|
8 |
|
|
|
31 |
choices = [choice.message.content for choice in api_response.choices]
|
32 |
return choices[0], choices
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
def save_history(history):
|
35 |
os.makedirs('logs', exist_ok=True)
|
36 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|