LLM AI Agent toy project - #2 Tool call

2026. 5. 29. 23:51·LLM AI Agent

목표

LLM이 필요한 도구를 직접 골라 실행할 수 있게끔 Agent 설계

 

코드

코드 링크: https://github.com/ybjeon/ai-agent-toyproject/blob/main/test_toolcall.py

 

1) test_toolcall.py - get_today_schedule() Tool call 정의

from langchain_core.tools import tool

@tool
def get_today_schedule() -> dict:
    """Retrieve today's calendar schedule."""
    today = TODAY # str(date.today())
    events = FAKE_CALENDAR.get(today, [])
    return {
        "date": today,
        "events": events if events else [],
        "message": f"You have {len(events)} event(s) today." if events else "No events scheduled for today.",
    }

 

 

2) test_toolcall.py - tool call을 포함한 agent 생성

from langchain.agents import create_agent
tools = [get_today_schedule, save_schedule, send_email, read_sms]
agent = create_agent(llm, tools, system_prompt="You are a helpful personal assistant.")

tool들을 포함한 create_agent 함수

 

 

결과

>>>>>>> User: What's on my schedule today?
2026-05-29 23:42:10 [INFO] HTTP Request: POST http://localhost:11434/api/chat "HTTP/1.1 200 OK"
2026-05-29 23:42:10 [INFO] [TOOL START] get_today_schedule | input: {}
2026-05-29 23:42:10 [INFO] [TOOL END]   output: content='{"date": "2026-05-05", "events": [{"time": "09:00", "title": "Team Standup Meeting"}, {"time": "14:00", "title": "Project Review"}, {"time": "18:00", "title": "Dinner Appointment"}], "message": "You have 3 event(s) today."}' name='get_today_schedule' tool_call_id='045c3771-c1c7-4ae2-b72a-47b62c24c8fc'
2026-05-29 23:42:10 [INFO] HTTP Request: POST http://localhost:11434/api/chat "HTTP/1.1 200 OK"

<<<<<<< Assistant: Today, May 5th, 2026, you have the following events scheduled:

- Team Standup Meeting at 09:00
- Project Review at 14:00
- Dinner Appointment at 18:00

You have a total of 3 events today.

 

'LLM AI Agent' 카테고리의 다른 글

LLM 출력에서 자주 보이는 <think> 태그  (0) 2026.05.31
LLM AI Agent toy project - #1 기본 LLM 테스트  (0) 2026.05.29
LLM AI Agent toy project - #3 MCP Server 예제 (python FastMCP)  (1) 2026.05.28
'LLM AI Agent' 카테고리의 다른 글
  • LLM 출력에서 자주 보이는 <think> 태그
  • LLM AI Agent toy project - #1 기본 LLM 테스트
  • LLM AI Agent toy project - #3 MCP Server 예제 (python FastMCP)
ybjeon.today
ybjeon.today
#Security #AI #LLM #일상 #공부 #연구, 프로필: https://ybjeon.today
  • ybjeon.today
    ybjeon's today
    ybjeon.today
  • 전체
    오늘
    어제
  • 링크

    • Github
    • Homepage
  • 블로그 메뉴

    • 전체 보기
    • Security
    • LLM AI Agent
    • AI Agent Security
    • Development
    • 방명록
  • 태그

    ToDo
    Security
    review
    NEWS
    llm
    ai
    coding
    Agent
  • 인기 글

    • 분류 전체보기 (16) N
      • Dev (4) N
      • Security (2)
      • AI Agent Security (5) N
      • LLM AI Agent (4)
      • Tech News (1) N
  • 공지사항

  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.6
ybjeon.today
LLM AI Agent toy project - #2 Tool call
상단으로

티스토리툴바