Skip to content

Commit

Permalink
검색 결과가 없을 경우 예외를 터트리는게 아니라 그냥 프롬프트만으로 openai로 요청하도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
stopmin committed Jul 17, 2024
1 parent 8839129 commit b5b092d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions app/rag_lang_chain/langchain_applied.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ async def request_rag_applied_openai(
)

# Step 1: Google Custom Search API를 사용하여 관련 정보 수집
google_results = await google_cse_retriever.retrieve(
original_text
) # FIXME: 왜 GoogleCSERetriever를 사용하는가? # pylint: disable=fixme
if not google_results:
raise HTTPException(status_code=404, detail="No results found from Google.")
google_results = await google_cse_retriever.retrieve(original_text)

# Step 2: 검색 결과를 벡터화하고 ChromaDB에 저장
chroma_db_manager = ChromaDBManager()
Expand All @@ -50,9 +46,12 @@ async def request_rag_applied_openai(
additional_info = await search.aget_relevant_documents(original_text, num_results=3)

# Step 4: 프롬프트 생성(원문 + 검색 결과 + 추가 정보)
rag_applied_prompt = await create_rag_applied_prompt(
original_prompt=system_prompt, relevant_info=search_results + additional_info
)
rag_applied_prompt = system_prompt
if search_results:
rag_applied_prompt = await create_rag_applied_prompt(
original_prompt=system_prompt,
relevant_info=search_results + additional_info,
)

# Step 5: OpenAI 요청 결과 반환
try:
Expand Down

0 comments on commit b5b092d

Please sign in to comment.