-
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.
- Loading branch information
Showing
23 changed files
with
124 additions
and
310 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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
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
File renamed without changes.
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,41 @@ | ||
from typing import List, Optional | ||
from datetime import datetime | ||
|
||
from fastapi import APIRouter, Depends, Body, Path, HTTPException, status | ||
from sqlalchemy.orm import Session | ||
|
||
from database import get_db | ||
from recommendations.schemas import RecommendationRequest, RecommendationResponse, BookmarkBase | ||
from recommendations.service import get_recommendations_service | ||
|
||
router = APIRouter( | ||
prefix="/recommendations", | ||
tags=["recommendations"], | ||
responses={404: {"description": "Not found"}} | ||
) | ||
|
||
|
||
@router.post( | ||
"/", | ||
response_model=RecommendationResponse, | ||
status_code=status.HTTP_200_OK, | ||
description="글 관련 페이지 추천", | ||
summary="글 관련 페이지 추천", | ||
response_description={ | ||
status.HTTP_200_OK: { | ||
"description": "글 관련 페이지 추천 성공" | ||
} | ||
} | ||
) | ||
async def recommend_pages( | ||
request: RecommendationRequest, | ||
db: Session = Depends(get_db) | ||
): | ||
# 사용자 정보를 가지고 구글 드라이브에 접속한다 | ||
# content_id를 가지고 온다 | ||
# 수정 사항을 embedding한다 | ||
# vector db에서 가장 가까운 n개의 문서를 가지고 온다 | ||
# n 개의 문서 중 유사도가 일정 수치 이하인 문서는 제외한다 | ||
# 가지고 온 문서들을 사용자에게 보여준다 | ||
|
||
return get_recommendations_service(request, db) |
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,25 @@ | ||
from typing import List, Optional | ||
from datetime import datetime | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
|
||
class UserInfo(BaseModel): | ||
pass | ||
|
||
|
||
class RecommendationRequest(BaseModel): | ||
content: str = Field(..., title="content", description="content", example="contentcontentcontentcontent") | ||
|
||
|
||
class BookmarkBase(BaseModel): | ||
user_id: Optional[int] = Field(default=None, title="user_id", description="북마크한 사용자의 user_id", example=1, ge=0) | ||
url: str = Field(..., title="url", description="북마크한 페이지의 url", example="https://mindorizip.tistory.com") | ||
title: Optional[str] = Field(default=None, title="title", description="북마크한 페이지의 title", example="마음의 소리") | ||
page_id: int = Field(..., title="page_id", description="북마크한 페이지의 page_id", example=1, ge=1) | ||
bookmark_id: int = Field(..., title="bookmark_id", description="북마크 id", example=1, ge=1) | ||
summary: Optional[str] = Field(default=None, title="summary", description="북마크한 페이지의 summary", example="마음의 소리") | ||
|
||
|
||
class RecommendationResponse(BaseModel): | ||
recommended_pages: List[BookmarkBase] |
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,52 @@ | ||
from datetime import datetime | ||
|
||
from fastapi import HTTPException | ||
from sqlalchemy.orm import Session | ||
from sqlalchemy.sql.expression import null | ||
|
||
from models import Bookmark, Content | ||
from recommendations.schemas import RecommendationRequest | ||
|
||
|
||
def get_recommendations_service(request: RecommendationRequest, db: Session): | ||
|
||
content = request.content | ||
|
||
response = { | ||
"recommended_pages": [ | ||
{ | ||
"url": "https://mindorizip.tistory.com", | ||
"user_id": 1, | ||
"title": "Mindorizip", | ||
"page_id": 1, | ||
"bookmark_id": 1, | ||
"summary": "마음의 소리" | ||
}, | ||
{ | ||
"url": "https://www.google.com", | ||
"user_id": 1, | ||
"title": "Google", | ||
"page_id": 2, | ||
"bookmark_id": 2, | ||
"summary": "구글" | ||
}, | ||
{ | ||
"url": "https://www.naver.com", | ||
"user_id": 1, | ||
"title": "Naver", | ||
"page_id": 3, | ||
"bookmark_id": 3, | ||
"summary": "네이버" | ||
}, | ||
{ | ||
"url": "https://www.daum.net", | ||
"user_id": 1, | ||
"title": "Daum", | ||
"page_id": 4, | ||
"bookmark_id": 4, | ||
"summary": "다음" | ||
} | ||
] | ||
} | ||
|
||
return response |
File renamed without changes.
Empty file.
Oops, something went wrong.