-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from SWM-SMART/dev
Dev
- Loading branch information
Showing
9 changed files
with
42 additions
and
28 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 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,12 +1,12 @@ | ||
from fastapi import APIRouter, Depends | ||
|
||
from app.schemas.context import Text, Context | ||
from app.schemas.context import QuestionText, Context | ||
from app.controller.llm import LLMController | ||
|
||
router = APIRouter() | ||
|
||
@router.post("/question", response_model=Text) | ||
def get_answer(context: Context) -> Text: | ||
@router.post("/question", response_model=QuestionText) | ||
def get_answer(context: Context) -> QuestionText: | ||
controller = LLMController() | ||
question = f"'{context.summary}'에서 {context.keyword}의 의미를 알려줘" | ||
return Text(text=controller.request_base(question)) | ||
return QuestionText(text=controller.request_base(question)) |
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,15 +1,19 @@ | ||
from fastapi import Depends | ||
from app.controller.llm import LLMController | ||
from langchain.schema.document import Document | ||
from langchain.text_splitter import CharacterTextSplitter | ||
|
||
from app.schemas.context import Keywords | ||
|
||
class KeywordsController: | ||
prompt = "Question: 키워드들을 뽑아서 '(', ',', ')'로 정리해서 알려줘 \\nAnswer: (" | ||
def __init__(self, llm: LLMController = Depends(LLMController)): | ||
def __init__(self, llm: LLMController): | ||
self.llm = llm | ||
|
||
def get_keywords(self, document: Document) -> Keywords: | ||
self.llm.set_document(document) | ||
answer = self.llm.request(self.prompt).content | ||
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=50) | ||
texts = text_splitter.split_documents(document) | ||
prompt = f"#Context: {texts} \\n#Question: 한글 키워드들을 20개 이내로 뽑아서 '(', ',', ')'로 정리해서 알려줘 \\n#Answer: (" | ||
|
||
answer = self.llm.request_base(prompt) | ||
return Keywords(keywords=list(map(lambda word: word.strip(), list(answer[1:-1].split(','))))) |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from app.schemas.mindmap import MindMap | ||
from app.schemas.database import DatabaseInfo | ||
from app.schemas.document import Document | ||
from app.schemas.context import Keywords, Text, Context | ||
from app.schemas.context import Keywords, Text, Context, QuestionText |
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