-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…on-logic(swm-405) Feat/#47/develop summary fragmentation logic(swm 405)
- Loading branch information
Showing
7 changed files
with
145 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Sroom-AI-Deploy | ||
name: Sroom-AI-Deploy-Main | ||
|
||
on: | ||
workflow_dispatch: | ||
|
@@ -33,22 +33,3 @@ jobs: | |
tmux send-keys -t server "python3 main.py server" C-m | ||
tmux send-keys -t celery "celery -A celery_app worker --concurrency=10 -l info" C-m | ||
- name: Deploy Test Server | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.AWS_SSH_TEST_HOST }} | ||
username: ubuntu | ||
key: ${{ secrets.SSH_SECRET_KEY }} | ||
script_stop: true | ||
script: | | ||
cd sroom-ai/ | ||
git pull | ||
pip3 install -r requirements.txt | ||
tmux send-keys -t celery "^C" C-m | ||
tmux send-keys -t server "^C" C-m | ||
tmux send-keys -t server "python3 main.py server" C-m | ||
tmux send-keys -t celery "celery -A celery_app worker --concurrency=2 -l info" C-m | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Sroom-AI-Deploy-Test | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: | ||
- main | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} | ||
aws-region: ap-northeast-2 | ||
|
||
- name: Deploy Test Server | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.AWS_SSH_TEST_HOST }} | ||
username: ubuntu | ||
key: ${{ secrets.SSH_SECRET_KEY }} | ||
script_stop: true | ||
script: | | ||
cd sroom-ai/ | ||
git fetch | ||
git checkout '${{ github.event.pull_request.head.ref }}' | ||
git pull | ||
pip3 install -r requirements.txt | ||
tmux send-keys -t celery "^C" C-m | ||
tmux send-keys -t server "^C" C-m | ||
tmux send-keys -t server "python3 main.py server" C-m | ||
tmux send-keys -t celery "celery -A celery_app worker --concurrency=2 -l info" C-m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import asyncio | ||
import datetime | ||
import re | ||
|
||
from main import constants | ||
from app.gpt import gpt | ||
|
||
|
||
async def generate_summary(scripts: dict, video_title: str): | ||
time_stamp, chunks = divide_chunk(scripts) | ||
summary_prompt = constants['prompt']['final_summary']['kr'] | ||
|
||
tasks = [gpt.request_gpt(summary_prompt + "\n script : " + chunk, | ||
constants['prompt']['final_summary']['system_message']) for idx, chunk in enumerate(chunks)] | ||
|
||
summaries = await asyncio.gather(*tasks) | ||
|
||
final_summary = '' | ||
for idx, summary in enumerate(summaries): | ||
time_delta = datetime.timedelta(seconds=int(time_stamp[idx])) | ||
time_format = str(time_delta) | ||
final_summary += ('<button id=\"' + time_format.replace(":", "") + '\" class=\"timestamp\" style=\"' | ||
'color:#FA5B3E;font-size: 1.125rem;line-height: 1.75rem;text-decoration-line:none;' | ||
'display:inline-block;background-color:rgba(250, 91, 62, 0.2);border-radius:0.25rem;padding:0.125rem 0.25rem;\">' + | ||
time_format + '</button>' + '\n') | ||
final_summary += summary + '\n \n ' | ||
|
||
final_summary = reformat_summary(final_summary) | ||
return final_summary, summaries | ||
|
||
|
||
def divide_chunk(scripts: dict): | ||
|
||
chunk_text = '' | ||
time_stamp = 0 | ||
|
||
time_stamps = [] | ||
chunks = [] | ||
for script in scripts: | ||
if len(chunk_text) > 3000: | ||
chunk_text.replace("[음악]", "") | ||
chunk_text.replace("[박수]", "") | ||
chunks.append(chunk_text) | ||
time_stamps.append(time_stamp) | ||
time_stamp = script['start'] | ||
chunk_text = script['text'] + ' ' | ||
else: | ||
chunk_text += script['text'] | ||
|
||
if len(chunk_text) < 1000: | ||
chunks[-1] += chunk_text | ||
else: | ||
time_stamps.append(time_stamp) | ||
chunks.append(chunk_text) | ||
|
||
return time_stamps, chunks | ||
|
||
|
||
def reformat_summary(summary: str): | ||
summary.replace("\#", "#") | ||
summary = re.sub(r"```", "", summary) | ||
return summary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters