Skip to content

Commit

Permalink
Merge pull request #94 from 2024-SummerBootcamp-Team/develop
Browse files Browse the repository at this point in the history
[main] main Merge
  • Loading branch information
dlwhsk0 authored Jul 21, 2024
2 parents 588d0f7 + 6e4b3a8 commit a2b2753
Show file tree
Hide file tree
Showing 17 changed files with 108 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/config/aws/s3Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def list_images_in_directory(character_name: str):
:return: 이미지 URL 리스트
"""
bucket_name = "teamh-bucket"
prefix = f"samples/{character_name}/" # 디렉토리 경로: 캐릭터 명
prefix = f"characters/{character_name}/" # 디렉토리 경로: 캐릭터 명

# Create an S3 client
s3_client = boto3.client('s3')
Expand Down
1 change: 1 addition & 0 deletions app/models/character.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ class Character(Base):
name = Column(String(20), nullable=False)
prompt = Column(Text, nullable=False)
tts_id = Column(String(45), nullable=False)
image_url = Column(String(500), nullable=False)

chats = relationship("Chat", back_populates="character")
3 changes: 2 additions & 1 deletion app/routers/api.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from fastapi import APIRouter
from . import chats, voices, images, tests
from . import chats, voices, images, tests, characters

router = APIRouter(
prefix="/api/v1"
)

router.include_router(characters.router)
router.include_router(chats.router)
router.include_router(voices.router)
router.include_router(images.router)
Expand Down
19 changes: 19 additions & 0 deletions app/routers/characters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session

from app.database.session import get_db
from app.schemas.character import CharacterList
from app.schemas.response import ResultResponseModel
from app.services import character_service

router = APIRouter(
prefix="/characters",
tags=["Characters"]
)


# 캐릭터 목록 조회
@router.get("", response_model=ResultResponseModel, summary="캐릭터 목록 조회", description="캐릭터 목록 및 정보를 조회합니다.")
def read_characters(db: Session = Depends(get_db), skip: int = 0, limit: int = 100):
characters = character_service.get_characters(db, skip=skip, limit=limit)
return ResultResponseModel(code=200, message="캐릭터 목록을 조회했습니다.", data=CharacterList(characters=characters))
2 changes: 1 addition & 1 deletion app/routers/voices.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async def create_voice(bubble_id: int, db: Session = Depends(get_db)):
def read_voices_in_chat_room(chat_id: int, db: Session = Depends(get_db)):
chat_service.get_chat_room(db, chat_id=chat_id)
voices = voice_service.get_voices_by_chat_id(db, chat_id=chat_id)
return ResultResponseModel(code=200, message="채팅방 별 목소리 목록을 조회했습니다.", data=VoiceBaseList(voices=voices))
return ResultResponseModel(code=200, message="채팅방 별 목소리 목록을 조회했습니다.", data=VoiceDetailList(voices=voices))


# 저장한 목소리 상세 조회
Expand Down
17 changes: 17 additions & 0 deletions app/schemas/character.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from pydantic import BaseModel
from datetime import datetime
from typing import List

class CharacterDetail(BaseModel):
id: int
name: str
image_url: str

class Config:
from_attributes = True

class CharacterList(BaseModel):
characters: List[CharacterDetail]

class Config:
from_attributes = True
1 change: 1 addition & 0 deletions app/schemas/voice.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class VoiceDetail(BaseModel):
id: int
chat_id: int
character: str
character_image: str
bubble_id: int
audio_url: str
content: str
Expand Down
13 changes: 10 additions & 3 deletions app/services/character_service.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
from sqlalchemy.orm import Session
from ..models.character import Character as CharacterModel
from ..models.character import Character
from ..schemas.character import CharacterDetail, CharacterList


def get_character(db: Session, character_id: int):
return db.query(CharacterModel).filter(CharacterModel.id == character_id).first()
return db.query(Character).filter(Character.id == character_id).first()


def get_character_by_name(db: Session, character_name: str):
return db.query(CharacterModel).filter(CharacterModel.name == character_name).first()
return db.query(Character).filter(Character.name == character_name).first()


def get_characters(db: Session, skip: int = 0, limit: int = 100):
characters = db.query(Character).filter(Character.is_deleted == False).offset(skip).limit(limit).all()
character_list = [CharacterDetail(id=character.id, name=character.name, image_url=character.image_url) for character in characters]
return character_list
13 changes: 12 additions & 1 deletion app/services/voice_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def get_voices(db: Session, skip: int = 0, limit: int = 100):
id=voice.id,
chat_id=voice.bubble.chat_id,
character=voice.bubble.chat.character.name,
character_image=voice.bubble.chat.character.image_url,
bubble_id=voice.bubble_id,
audio_url=voice.audio_url,
content=voice.content,
Expand All @@ -26,7 +27,17 @@ def get_voices(db: Session, skip: int = 0, limit: int = 100):

# 채팅방 별 목소리 목록 조회
def get_voices_by_chat_id(db: Session, chat_id: int):
return db.query(Voice).join(Voice.bubble).filter(Bubble.chat_id == chat_id, Voice.is_deleted == False).all()
voices = db.query(Voice).join(Voice.bubble).filter(Bubble.chat_id == chat_id, Voice.is_deleted == False).all()
return [VoiceDetail(
id=voice.id,
chat_id=voice.bubble.chat_id,
character=voice.bubble.chat.character.name,
character_image=voice.bubble.chat.character.image_url,
bubble_id=voice.bubble_id,
audio_url=voice.audio_url,
content=voice.content,
created_at=voice.created_at
) for voice in voices]


# 단일 목소리 상세 조회
Expand Down
56 changes: 44 additions & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
fastapi-server:
container_name: fastapi
build: app/
container_name: fastapi-server
volumes:
- ~/.aws:/root/.aws
- ./app:/app
Expand All @@ -19,72 +19,104 @@ services:
path: app/requirements.txt
target: app/
restart: always
networks:
- teamhnet



redis:
container_name: redis
image: redis
ports:
- "6379:6379"
container_name: redis


networks:
- teamhnet


prometheus:
container_name: prometheus
image: prom/prometheus:latest
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
- ./monitoring/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
command:
- '--config.file=/etc/prometheus/prometheus.yml'
ports:
- "9090:9090"
container_name: prometheus
networks:
- teamhnet


grafana:
container_name: grafana
image: grafana/grafana:latest
volumes:
- ./monitoring/grafana/datasources:/etc/grafana/provisioning/datasources/
- ./monitoring/grafana/dashboards:/etc/grafana/provisioning/dashboards/
ports:
- "3000:3000"
networks:
- teamhnet


cadvisor:
container_name: cadvisor
image: gcr.io/cadvisor/cadvisor:latest

ports:
- "8080:8080"
volumes:
- /:/rootfs:ro
- /var/run:/var/run:ro
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro

privileged: true
networks:
- teamhnet


# elasticsearch:
# container_name: elasticsearch
# image: docker.elastic.co/elasticsearch/elasticsearch:7.17.4
# environment:
# - discovery.type=single-node
# ports:
# - "9200:9200"
# networks:
# - teamhnet
#
#
# logstash:
# container_name: logstash
# image: docker.elastic.co/logstash/logstash:7.17.4
# ports:
# - "5044:5044"
# volumes:
# - ./elk/logstash/pipeline/logstash.conf:/usr/share/logstash/pipeline/logstash.conf
# - ./elk/logstash/logstash.yml:/usr/share/logstash/config/logstash.yml
# - ./monitoring/elk/logstash/pipeline/logstash.conf:/usr/share/logstash/pipeline/logstash.conf
# - ./monitoring/elk/logstash/logstash.yml:/usr/share/logstash/config/logstash.yml
# networks:
# - teamhnet
#
#
# kibana:
# container_name: kibana
# image: docker.elastic.co/kibana/kibana:7.17.4
# ports:
# - "5601:5601"
# environment:
# ELASTICSEARCH_HOSTS: "http://elasticsearch:9200"
# networks:
# - teamhnet
#
#
# filebeat:
# container_name: filebeat
# image: docker.elastic.co/beats/filebeat:7.17.4
# volumes:
# - ./elk/filebeat/filebeat.yml:/usr/share/filebeat/filebeat.yml # 경로 수정
# - ./monitoring/elk/filebeat/filebeat.yml:/usr/share/filebeat/filebeat.yml # 경로 수정
# - ./app/logs:/app/logs:ro
# depends_on:
# - logstash
# networks:
# - teamhnet


networks:
teamhnet:
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit a2b2753

Please sign in to comment.