더북(TheBook)
# OpenAI LLM을 활용하여 정답만 추출
client = openai.OpenAI()  # OpenAI 최신 API 사용
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "system", "content": "You are an AI assistant. Only provide the exact answer to the question without any explanations."},
        {"role": "user", "content": f"다음 내용을 기반으로 질문에 대한 정답만 출력하세요:\n\n{retrieved_text}\n\n정답: "}
    ],
    temperature=0
)

# 정답 출력
print("🔹 정답:", response.choices[0].message.content)

FAISS와 유사하죠? 다른 벡터 데이터베이스에 대한 사용도 유사하므로 예시는 여기까지 알아보겠습니다.

신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.