From 750d16b0a0ffab8e16819cd24c846f6036006d76 Mon Sep 17 00:00:00 2001 From: uommou Date: Sun, 26 May 2024 00:26:55 +0900 Subject: [PATCH 1/5] =?UTF-8?q?fix:=20port=20number=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/database/connect_rds.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/database/connect_rds.py b/app/database/connect_rds.py index c1a9ee4..12ee3de 100644 --- a/app/database/connect_rds.py +++ b/app/database/connect_rds.py @@ -9,6 +9,7 @@ def get_rds_connection(): return pymysql.connect( host=os.getenv('RDS_HOST'), + port=3306, user=os.getenv('RDS_USER'), password=os.getenv('RDS_PASSWORD'), database=os.getenv('RDS_DATABASE'), From 53ae6d4d590579def184cb69678556b10ea05027 Mon Sep 17 00:00:00 2001 From: uommou Date: Sun, 26 May 2024 16:23:30 +0900 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20gpt-4o=EB=A1=9C=20=EB=AA=A8=EB=8D=B8?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/prompt/openai_config.ini | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/prompt/openai_config.ini b/app/prompt/openai_config.ini index 99eaac1..8d7ec16 100644 --- a/app/prompt/openai_config.ini +++ b/app/prompt/openai_config.ini @@ -1,24 +1,24 @@ [NESS_NORMAL] TEMPERATURE = 0.5 MAX_TOKENS = 2048 -MODEL_NAME = gpt-4 +MODEL_NAME = gpt-4o [NESS_CASE] TEMPERATURE = 0 MAX_TOKENS = 2048 -MODEL_NAME = gpt-4 +MODEL_NAME = gpt-4o [NESS_RECOMMENDATION] TEMPERATURE = 1 MAX_TOKENS = 2048 -MODEL_NAME = gpt-4 +MODEL_NAME = gpt-4o [NESS_TAGS] TEMPERATURE = 0.5 MAX_TOKENS = 2048 -MODEL_NAME = gpt-4 +MODEL_NAME = gpt-4o [NESS_EMAIL] TEMPERATURE = 0.5 MAX_TOKENS = 2048 -MODEL_NAME = gpt-4 \ No newline at end of file +MODEL_NAME = gpt-4o \ No newline at end of file From d148fc8acb2fa80038ddd7a808d7a3f4d628939f Mon Sep 17 00:00:00 2001 From: uommou Date: Sun, 26 May 2024 16:55:49 +0900 Subject: [PATCH 3/5] =?UTF-8?q?fix:=20env=20=ED=8C=8C=EC=9D=BC=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cicd.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 4708120..7b8cb07 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -27,6 +27,10 @@ jobs: run: | echo "CHROMA_DB_IP_ADDRESS=${{ secrets.CHROMA_DB_IP_ADDRESS }}" >> .env echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> .env + echo "RDS_HOST=${{ secrets.RDS_HOST }}" >> .env + echo "RDS_USER=${{ secrets.RDS_USER }}" >> .env + echo "RDS_PASSWORD=${{ secrets.RDS_PASSWORD }}" >> .env + echo "RDS_DATABASE=${{ secrets.RDS_DATABASE }}" >> .env shell: bash - name: Setup docker buildx From 87b652889ee300a58f0cd4244448a324a4714d2a Mon Sep 17 00:00:00 2001 From: uommou Date: Sun, 26 May 2024 17:17:13 +0900 Subject: [PATCH 4/5] =?UTF-8?q?feat:=20=EC=B9=B4=ED=85=8C=EA=B3=A0?= =?UTF-8?q?=EB=A6=AC=20=EC=BB=AC=EB=9F=AC=EC=BD=94=EB=93=9C=EC=99=80=20?= =?UTF-8?q?=EB=84=98=EB=B2=84=20=EB=A6=AC=ED=84=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cicd.yml | 4 ++ app/prompt/openai_prompt.py | 73 ++++++++++++++++++++----------------- app/routers/chat.py | 10 +++-- 3 files changed, 50 insertions(+), 37 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 7b8cb07..da629c8 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -18,6 +18,10 @@ jobs: env: OPENAI_API_KEY: ${{secrets.OPENAI_API_KEY}} CHROMA_DB_IP_ADDRESS: ${{secrets.CHROMA_DB_IP_ADDRESS}} + RDS_HOST: ${{ secrets.RDS_HOST }} + RDS_USER: ${{ secrets.RDS_USER }} + RDS_PASSWORD: ${{ secrets.RDS_PASSWORD }} + RDS_DATABASE: ${{ secrets.RDS_DATABASE }} steps: - name: Checkout diff --git a/app/prompt/openai_prompt.py b/app/prompt/openai_prompt.py index 2fff551..21f6b68 100644 --- a/app/prompt/openai_prompt.py +++ b/app/prompt/openai_prompt.py @@ -73,13 +73,16 @@ class Template: User Chat: {question} Answer: """ + chat_type_stt_template = """ You should keep in mind that this user's input was written using speech to text technology. Therefore, there may be inaccuracies in the text due to errors in the STT process. You need to consider this aspect when performing the given task. """ + chat_type_user_template = """ """ + case1_template = """ {persona} {chat_type} @@ -88,39 +91,43 @@ class Template: """ case2_template = """ - {persona} - {chat_type} - The user's input contains information about a new event they want to add to their schedule. You have two tasks to perform: - - 1. Respond kindly to the user's input. YOU MUST USE {output_language} TO RESPOND TO THE USER INPUT. - 2. Organize the event the user wants to add into a json format for saving in a database. The returned json will have keys for info, location, person, start_time, end_time, and category. - - info: Summarizes what the user wants to do. This value must always be present. - - location: If the user's event information includes a place, save that place as the value. - - person: If the user's event mentions a person they want to include, save that person as the value. - - start_time: If the user's event information includes a specific date and time, save that date and time in datetime format. Dates should be organized based on the current time at the user's location. Current time is {current_time}. - - end_time: If the user's event information includes an end time, save that date and time in datetime format. - - category: Choose the most appropriate category for the event from the following list: {categories}. - Separate the outputs for tasks 1 and 2 with a special token . - - Example for one-shot learning: - - User input: I have a meeting with Dr. Smith at her office on March 3rd from 10am to 11am. - - Response to user: - Shall I add your meeting with Dr. Smith at her office on March 3rd from 10am to 11am to your schedule? - - {{ - "info": "meeting with Dr. Smith", - "location": "Dr. Smith's office", - "person": "Dr. Smith", - "start_time": "2023-03-03T10:00:00", - "end_time": "2023-03-03T11:00:00", - "category": "Work" - }} - - User input: {question} - - Response to user: + {persona} + {chat_type} + The user's input contains information about a new event they want to add to their schedule. You have two tasks to perform: + + 1. Respond kindly to the user's input. YOU MUST USE {output_language} TO RESPOND TO THE USER INPUT. + 2. Organize the event the user wants to add into a json format for saving in a database. The returned json will have keys for info, location, person, start_time, end_time, and category. The category should include the name, id, and color. + - info: Summarizes what the user wants to do. This value must always be present. + - location: If the user's event information includes a place, save that place as the value. + - person: If the user's event mentions a person they want to include, save that person as the value. + - start_time: If the user's event information includes a specific date and time, save that date and time in datetime format. Dates should be organized based on the current time at the user's location. Current time is {current_time}. + - end_time: If the user's event information includes an end time, save that date and time in datetime format. + - category: Choose the most appropriate category for the event from the following list: {categories}. The category should include the name, id, and color. + Separate the outputs for tasks 1 and 2 with a special token . + + Example for one-shot learning: + + User input: I have a meeting with Dr. Smith at her office on March 3rd from 10am to 11am. + + Response to user: + Shall I add your meeting with Dr. Smith at her office on March 3rd from 10am to 11am to your schedule? + + {{ + "info": "meeting with Dr. Smith", + "location": "Dr. Smith's office", + "person": "Dr. Smith", + "start_time": "2023-03-03T10:00:00", + "end_time": "2023-03-03T11:00:00", + "category": {{ + "name": "Work", + "id": 1, + "color": "#FF0000" + }} + }} + + User input: {question} + + Response to user: """ case3_template = """ diff --git a/app/routers/chat.py b/app/routers/chat.py index 70fb275..605f78a 100644 --- a/app/routers/chat.py +++ b/app/routers/chat.py @@ -107,9 +107,11 @@ async def get_langchain_schedule(data: PromptRequest, chat_type_prompt): print("running case 2") member_id = data.member_id categories = fetch_category_classification_data(member_id) - # 카테고리 데이터를 텍스트로 변환 (JSON 형식으로 변환) - categories_text = ", ".join([category['name'] for category in categories]) - print(categories_text) + # 카테고리 데이터를 딕셔너리 형태로 변환 + categories_dict = [ + {"name": category['name'], "id": category['category_id'], "color": category['color']} + for category in categories + ] # description: use langchain config_normal = config['NESS_NORMAL'] @@ -136,7 +138,7 @@ async def get_langchain_schedule(data: PromptRequest, chat_type_prompt): question=question, current_time=current_time, chat_type=chat_type_prompt, - categories=categories_text # 카테고리 데이터를 프롬프트에 포함 + categories=categories_dict # 카테고리 데이터를 프롬프트에 포함 ) ) From 8476e6d0c02b7e291dcd05f9638a3f38b241a00b Mon Sep 17 00:00:00 2001 From: uommou Date: Sun, 26 May 2024 17:34:05 +0900 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20docker=20run=20=EC=8B=9C=20=ED=99=98?= =?UTF-8?q?=EA=B2=BD=EB=B3=80=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cicd.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index da629c8..ec34fab 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -92,4 +92,8 @@ jobs: docker run -d -p 80:80 --name ${{ env.NAME }} --restart always \ -e CHROMA_DB_IP_ADDRESS=${{ secrets.CHROMA_DB_IP_ADDRESS }} \ -e OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} \ + -e RDS_HOST=${{ secrets.RDS_HOST }} \ + -e RDS_USER=${{ secrets.RDS_USER }} \ + -e RDS_PASSWORD=${{ secrets.RDS_PASSWORD }} \ + -e RDS_DATABASE=${{ secrets.RDS_DATABASE }} \ ${{ env.DOCKER_IMAGE }}:latest \ No newline at end of file