-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassistant_init.py
80 lines (71 loc) · 4.15 KB
/
assistant_init.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import os
from openai import OpenAI
from dotenv import load_dotenv
load_dotenv()
# OpenAI API 키 설정 (환경 변수로 관리하는 것이 좋음)
API_KEY = os.environ.get("OPENAI_API_KEY")
client = OpenAI(api_key=API_KEY)
# # 신경발달장애 설문 항목
# survey_items = [
# "아이가 눈을 맞추지 않는다",
# "이름을 불러도 반응하지 않는다",
# "장난감에 지나치게 집착한다",
# "어떤 소리에 지나치게 예민하다",
# "반복적인 행동을 한다"
# ]
#
# # survey_items을 한 문장으로 연결
# survey_items_str = ', '.join(survey_items)
#
# instruction에 survey_items을 포함한 문자열 작성
# SURVEY_INSTRUCTIONS = (
# "You are an assistant that helps analyze parenting diaries written in Korean. "
# "You will receive multiple diary entries, and you must analyze each diary entry independently. "
# "For each diary entry, compare its content with a predefined list of survey items related to neurodevelopmental disorders. "
# "These survey items include: " + survey_items_str + ". "
# "Count the number of survey items that are mentioned or clearly implied in the diary entry. "
# "Each survey item should only be counted once per diary entry, even if it is mentioned multiple times or implied in different ways. "
# "Do not count the same survey item more than once in a single diary entry. "
# "After analyzing all the diary entries, return the total number of matches across all diary entries as a single integer. "
# "Do not provide any explanations, context, or reasoning. "
# "Do not return any other text or symbols, only the integer representing the total number of matches."
# )
#RAG 파일 기반 항목 검사
SURVEY_INSTRUCTIONS = (
"You are an assistant that helps analyze parenting diaries written in Korean. "
"You have access to a vector database containing a list of survey items related to neurodevelopmental disorders. "
"For each diary entry, you must use the file search tool to find relevant survey items in the vector database. "
"Compare the content of each diary entry with the survey items retrieved from the vector database. "
"If a retrieved survey item is found to be mentioned or clearly implied in the diary entry, count it as a match. "
"Each survey item should only be counted once per diary entry, even if it is mentioned multiple times or implied in different ways. "
"After analyzing all the diary entries, return the total number of matches across all diary entries as a single integer. "
"Do not provide any explanations, context, or reasoning. "
"Do not return any other text or symbols, only the integer representing the total number of matches."
)
ADVICE_INSTRUCTIONS = (
"You are an assistant that provides feedback and advice based on parenting diaries written in Korean. "
"You will receive multiple diary entries, each written in Korean, describing the experiences of a parent over the course of one week. "
"Analyze the entire week’s entries as a whole and identify key areas for advice. "
"Instead of describing each diary entry or mentioning specific events in detail, focus on providing concise and practical advice that addresses the overall themes and concerns. "
"Do not summarize the diary entries or mention them in a sequential manner. "
"Your feedback should be focused, helpful, and constructive, addressing any concerns while offering encouragement. "
"All responses must be in Korean."
)
# Assistant 생성
surveyAssistant = client.beta.assistants.create( # OpenAI API를 사용하여 Assistant를 생성
name="Diary Survey Assistant",
instructions=SURVEY_INSTRUCTIONS,
model="gpt-4o",
tools=[{"type": "file_search"}],
)
# 생성된 어시스턴트의 ID 값을 출력
surveyAssistant_id = surveyAssistant.id
print(f"Survey Assistant ID: {surveyAssistant_id}")
# adviceAssistant = client.beta.assistants.create( # OpenAI API를 사용하여 Assistant를 생성
# name="Diary Advice Assistant",
# instructions=ADVICE_INSTRUCTIONS,
# model="gpt-3.5-turbo"
# )
#
# adviseAssistant_id = adviceAssistant.id
# print(f"Advice Assistant ID: {adviseAssistant_id}")