도구 연결로 Agentic RAG 활성화
이제 의미론적 유사도를 사용해 가전제품 설명서를 검색하는 사용자 정의 도구가 준비되어 있어요. 이번 연습에서는 그 도구를 에이전트에 연결해, 설명서 내용을 바탕으로 질문에 답할 수 있도록 하겠습니다.
백그라운드에서는 이미 다음에 접근할 수 있어요:
- 검색 가능한 설명서 콘텐츠를 담은
vector_store변수 - 의미론적 검색을 수행하는
ApplianceSearchTool - 에이전트용으로 사전 구성된 언어 모델을 담은
model변수
목표는 모든 것을 서로 연결해, 에이전트가 도구를 사용해 친절한 가전제품 도우미처럼 질문에 답하도록 만드는 것입니다.
이 연습은 강의의 일부입니다
Hugging Face smolagents로 AI 에이전트 만들기
연습 안내
vector_store를 전달해ApplianceSearchTool을 인스턴스화하세요.CodeAgent를 초기화할 때appliance_tool을 tools 목록에 추가하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Create appliance search tool
appliance_tool = ApplianceSearchTool(____)
# Create AI assistant for appliance help
assistant = CodeAgent(
tools=[____],
model=model,
instructions="Help with appliance questions using manual information. Search multiple times if needed for complete answers.",
verbosity_level=1,
max_steps=6
)
result = assistant.run("If the AC isn’t cooling and shows error E1, what should I check and what’s the next step?")
print(result)