랭체인 코리아
팔로워85명
주최대회0개
Competition
전체보기종료
[본선] LangChain KR x NAVER Cloud 생성형 AI 서비스 개발 프로젝트 지원하기
랭체인 코리아
100만원 네이버페이 + 150만원 크레딧
[본선] LangChain KR x NAVER Cloud 생성형 AI 서비스 개발 프로젝트 지원하기
랭체인 코리아
100만원 네이버페이 + 150만원 크레딧
종료
LangChain KR x NAVER Cloud 생성형 AI 서비스 개발 프로젝트 지원하기
랭체인 코리아
100만원 네이버페이 + 150만원 크레딧
LangChain KR x NAVER Cloud 생성형 AI 서비스 개발 프로젝트 지원하기
랭체인 코리아
100만원 네이버페이 + 150만원 크레딧
종료
랭챗 - 2024년 신년축하파티룸
랭체인 코리아
랭챗 - 2024년 신년축하파티룸
랭체인 코리아
종료
Papers With Chat
랭체인 코리아
Papers With Chat
랭체인 코리아
종료
#무료 #대전 #코드제공 [랭체인러닝데이] 고객요청(주문, 예약, 민원 등) 접수 챗봇 만들기
랭체인 코리아
#무료 #대전 #코드제공 [랭체인러닝데이] 고객요청(주문, 예약, 민원 등) 접수 챗봇 만들기
랭체인 코리아
Learning
전체보기종료
랭체인코리아 밋업 2025Q2
랭체인 코리아
랭체인코리아 밋업 2025Q2
랭체인 코리아
종료
[에이전틱AI 랭체인코리아 밋업] AutoGen를 활용한 기업을 위한 멀티에이전트 구축
랭체인 코리아
[에이전틱AI 랭체인코리아 밋업] AutoGen를 활용한 기업을 위한 멀티에이전트 구축
랭체인 코리아
종료
[에이전틱AI 랭체인코리아 밋업] Copilot Studio를 활용한 에이전틱AI 시스템 구축
랭체인 코리아
[에이전틱AI 랭체인코리아 밋업] Copilot Studio를 활용한 에이전틱AI 시스템 구축
랭체인 코리아
종료
[에이전틱AI 랭체인코리아 밋업] CrewAI를 활용한 에이전틱AI 시스템 구축
랭체인 코리아
[에이전틱AI 랭체인코리아 밋업] CrewAI를 활용한 에이전틱AI 시스템 구축
랭체인 코리아
종료
[에이전틱AI 랭체인코리아 밋업] Microsoft Magnetic-One를 활용한 에이전틱AI 시스템 구축
랭체인 코리아
[에이전틱AI 랭체인코리아 밋업] Microsoft Magnetic-One를 활용한 에이전틱AI 시스템 구축
랭체인 코리아
종료
[에이전틱AI 랭체인코리아 밋업] 에이전틱 ai와 생산성의 미래 | RAG와 통합 검색 전략
랭체인 코리아
[에이전틱AI 랭체인코리아 밋업] 에이전틱 ai와 생산성의 미래 | RAG와 통합 검색 전략
랭체인 코리아
종료
[에이전틱AI 랭체인코리아 밋업] 에이전틱 서치 시스템 구축 | 높아진 Autonomy Level을 중심으로
랭체인 코리아
[에이전틱AI 랭체인코리아 밋업] 에이전틱 서치 시스템 구축 | 높아진 Autonomy Level을 중심으로
랭체인 코리아
Training
전체보기진행중
OPRO #3 - 외판원 순회 문제
랭체인 코리아
OPRO #3 - 외판원 순회 문제
랭체인 코리아
진행중
OPRO #2 - 선형회귀 최적화
랭체인 코리아
OPRO #2 - 선형회귀 최적화
랭체인 코리아
진행중
OPRO #1 - 업다운 게임
랭체인 코리아
OPRO #1 - 업다운 게임
랭체인 코리아
진행중
OPRO #1 - 준비하기
랭체인 코리아
OPRO #1 - 준비하기
랭체인 코리아
진행중
LCEL #0 - 준비하기
랭체인 코리아
LCEL #0 - 준비하기
랭체인 코리아
진행중
LCEL #10 - 라우팅 체인
랭체인 코리아
LCEL #10 - 라우팅 체인
랭체인 코리아
진행중
LCEL #9 - Tool 체인
랭체인 코리아
LCEL #9 - Tool 체인
랭체인 코리아
Chat
전체보기Forum
전체보기어제 저녁, 한빛미디어 리더스홀에서 열린 랭체인코리아 밋업 2025Q2가 성황리에 마무리되었습니다.120명 정원 모두 마감된 가운데, LangChain에 진심인 개발자분들이 모여 멀티에이전트 아키텍처와 LangGraph에 대한 뜨거운 관심을 나누었습니다. 이번 밋업에서는 다음 주제로 이야기를 나눴습니다이경록 님의 “LangGraph를 활용한 효율적인 멀티 에이전트 협업 시스템 구축”우성우 님의 “LangGraph로 따라해보는 멀티에이전트 아키텍처”김태영 님의 “A2A 관련 최신 주제” LangGraph 기반의 멀티에이전트, 실제로 구현 코드와 사례에 관심을 가졌으며,발표 사이사이 자연스럽게 참석자분들의 질문, 고민까지 생생하게 오고 갔습니다.LangChain interrupt참여 인사이트가 랭체인 생태계와 국내 커뮤니티의 연결 지점에 대해 함께 고민해보는 시간도 의미 있었습니다. 이번 밋업을 함께 기획해주신 한빛앤, 그리고 든든한 AI Factory에 진심으로 감사드리며,참여해주신 커뮤니티 멤버분들께 감사인사를 드립니다.앞으로 찾아올 랭체인 밋업도 기대해주세요!
Hello, everyone! This is Taeyoung Kim from LangChain Korea. 😄 Our LangChain Korea 2025Q1 Meetup on the theme of "Agentic AI" was a great success, with a total of 164 attendees (143 participants, 11 speakers, and 10 organizers & staff)! 🎉 This event focused on Agentic AI, a rising trend in the AI industry, covering: Single-agent systems, Multi-agent architectures, LangGraph, Various frameworks and real-world applications. A total of 11 expert speakers delivered sessions packed with practical insights and case studies that can be directly applied to real-world projects. 💡 Now, let's take a look at some highlights from the event! 📸🎬 Behind the Scenes: Getting Ready!📍 The meetup took place on the 13th floor of Microsoft Korea! The spacious venue, large screens, and well-arranged tables made it an ideal setting for presentations. ❄️ Despite the snowy weather across the country, many attendees traveled from afar to join us—thank you for your dedication! 🙏🎥 Special Message from LangChain Team's Jess!Jess from LangChain Team sent a special message celebrating our event! 🎊 She also shared the latest updates on the Interrupt(https://interrupt.langchain.com/). ✨ We truly appreciate the warm support from afar! 💙 💙 Consistent Support from Microsoft Korea & Space-S🎙️ Director Soyoung Lee from Microsoft Korea delivered a welcome speech! Fun fact: reserving an entire floor for an event requires months of preparation, and Microsoft's staff provided incredible support throughout the event! 👀 A huge thank you to Microsoft Korea for sponsoring our venue! 🙌 🚀 CEO Choongil Lee also shared inspiring words about building "Warm AI" through innovation. Thank you for your continued support!🏆 Exciting News! 🎉🥳 TeddyNote (Kyungrok Lee) has been officially appointed as a LangChain Ambassador! A huge congratulations! 👏👏👏📅 Session Schedule🔥 A non-stop, 6-hour knowledge-packed event from 3:00 PM to 9:00 PM! The dedication from our participants was truly inspiring. 💪 For the next meetup, we plan to include networking opportunities and a dinner break! 😆⏰ Session ListTimeSessionSpeaker15:00 - 15:25Building Multi-Agent Collaborative Networks with LangGraphKyungrok Lee (BrainCrew)15:30 - 15:55Building Agentic AI Systems with AssistWorksTaeyoung Kim (AI Factory)16:00 - 16:25Building Systems with PydanticAIJungjoon Heo (Engineer)16:30 - 16:55The Future of Search in the Agentic AI EraSeungyoon Baek (Engineer)17:00 - 17:25AI Collaboration Systems Using OpenAI SwarmHogan Seo (Korea Atomic Energy Research Institute)17:30 - 17:55Building an Agentic Search System: A Focus on Autonomy LevelsHoon Heo (Engineer)18:30 - 18:55The Future of Productivity with Agentic AIJiwon Seol (Engineer)19:00 - 19:25System Development with Microsoft Magentic-OneSeongjae Yoon (AI Consultant)19:30 - 19:55Building Agentic AI Systems with CrewAIJinhyung Lee (Engineer)20:00 - 20:25Building AI Systems with Copilot StudioHyunah Yoo (IT Content Creator)20:30 - 20:55Developing Multi-Agent Systems for Enterprises with AutoGenWonseok Jung (AI Researcher)15:00 ~ 15:25 Building Multi-Agent Collaborative Networks with LangGraph, Kyungrok Lee (BrainCrew)15:30 ~ 15:55 Building Agentic AI Systems with AssiWorks, Taeyoung Kim (AI Factory)16:00 ~ 16:25 Building Systems with PydanticAI, Jungjoon Heo (Engineer)16:30 ~ 16:55 The Future of Search in the Agentic AI Era, Seungyoon Baek (Engineer)17:00 ~ 17:25 AI Collaboration Systems Using OpenAI Swarm, Hogan Seo (Korea Atomic Energy Research Institute)17:30 ~ 17:55 Building an Agentic Search System: A Focus on Autonomy Levels, Hoon Heo (Engineer)18:30 ~ 18:55 The Future of Productivity with Agentic AI, Jiwon Seol (Engineer)19:00 ~ 19:25 System Development with Microsoft Magentic-One, Seongjae Yoon (AI Consultant)19:30 ~ 19:55 Building Agentic AI Systems with CrewAI, Jinhyung Lee (Engineer)20:00 ~ 20:25 Building AI Systems with Copilot Studio, Hyunah Yoo (IT Content Creator)20:30 ~ 20:55 Developing Multi-Agent Systems for Enterprises with AutoGen, Wonseok Jung (AI Researcher)🔥 The Unstoppable Passion of Our Participants!📚 From 3:00 PM to 9:00 PM, without breaks, fully focused on learning! Participants actively engaged in discussions, knowledge sharing, and deep dives into Agentic AI. For the next event, we will add networking and dinner breaks to make it even better! 😆 📸 Here’s a snapshot of our final “chain pose” of LangChain group photo! 📷💪 LangChain Korea Organizer Team🎤 A huge shoutout to the LangChain Korea organizers who planned, prepared, and managed this amazing event! 👏 (From left to right: Taeyoung Kim, Seoyeon Jang, Jiseok Lee, Hyunah Yoo, Mijeong Jeon) Thank you for making this possible! 💙 Please continue to support and engage with the LangChain Korea Community!🚀 Stay Tuned for the Next Meetup! We’ll be back with even more valuable content and networking opportunities! Thank you all, and see you next time! 🙌💙📢 Presentation Materials & Recorded Sessions 🎥📑We will soon share presentation slides and recorded videos with attendees! ⏳📩 Stay tuned for updates, and get ready to revisit the key insights from the event! 🚀✨
안녕하세요! 랭체인코리아의 김태영입니다. 😄 지난 랭체인코리아 2025Q1 밋업이 "에이전틱 AI"를 주제로 총 164명(참가자 143명, 연사 11명, 오거나이저 및 스태프 10명)이 모여 성황리에 마무리되었습니다! 🎉 이번 밋업에서는 최근 AI 업계에서 주목받고 있는 에이전틱 AI를 중심으로 진행되었으며, 단일 에이전트부터 멀티 에이전트 시스템과 다양한 프레임워크까지 폭넓게 다뤘습니다. 총 11명의 전문가가 각기 다른 세션에서 실무에서 바로 적용할 수 있는 기술과 다양한 사례를 공유해 주셨는데요.💡 함께 현장 스케치를 살펴볼까요? 📸🎬 준비하는 현장부터 시작!📍 이번 밋업 장소는 한국마이크로소프트 13층이었습니다! 넓고 쾌적한 공간 덕분에 긴 스크린과 넓은 책상이 마련되어 있어 발표 슬라이드를 보기에 최적이었어요. ❄️ 전국 곳곳에 눈이 내리는 날씨에도 멀리 지방에서 와주신 참가자분들께 진심으로 감사드립니다! 🙏🎥 LangChain Team의 Jess님 축전!LangChain Team의 Jess님께서 본 행사를 위해 축전을 보내주셨습니다! 🎊 또한, 최신 소식인 Interrupt 행사(https://interrupt.langchain.com/) 도 함께 소개해 주셨어요.✨ 이렇게 멀리서도 따뜻한 인사를 전해주셔서 감사드립니다! 💙 변함없는 후원: 한국마이크로소프트 & 대덕특구 Space-S🎙️ 마이크로소프트 이소영 이사님께서 환영 인사를 전해주셨습니다! 사실 한 층 전체를 예약하려면 몇 달 전부터 준비해야 하고, 행사 당일에도 마이크로소프트 직원분들의 서포트가 필요하다는 사실, 알고 계셨나요? 👀 매번 장소를 후원해 주시는 마이크로소프트에 다시 한번 감사드립니다. 🙌🚀 이충일 대표님께서 "따뜻한 AI"를 만들기 위한 메시지도 전해주셨습니다. 감사합니다!🏆 축하할 소식! 🎉🥳 테디노트(이경록)님께서 랭체인 공식 엠배서더로 선정되셨습니다! 이 자리를 빌려 진심으로 축하드립니다! 👏👏👏📅 세션 일정🔥 오후 3시부터 밤 9시까지, 6시간 논스톱 세션! 참가자분들의 열정이 정말 대단했는데요! 💪 다음 밋업에서는 네트워킹 및 저녁 시간도 마련해 보겠습니다. 😆⏰ Session List시간세션발표자15:00 ~ 15:25LangGraph를 활용한 멀티에이전트 협업 네트워크 시스템 구축이경록 (브레인크루)15:30 ~ 15:55어시웍스를 활용한 에이전틱 AI 시스템 구축김태영 (인공지능팩토리)16:00 ~ 16:25PydanticAI를 활용한 시스템 구축 방법허정준 (Engineer)16:30 ~ 16:55에이전틱 AI가 가져올 검색의 미래백승윤 (Engineer)17:00 ~ 17:25OpenAI Swarm을 활용한 AI 협업 시스템 구축서호건 (한국원자력연구원)17:30 ~ 17:55에이전틱 서치 시스템 구축 - 높아진 Autonomy Level을 중심으로허훈 (Engineer)18:30 ~ 18:55에이전틱 AI와 생산성의 미래설지원 (Engineer)19:00 ~ 19:25Microsoft Magentic-One을 활용한 시스템 구축윤성재 (AI 컨설턴트)19:30 ~ 19:55CrewAI를 활용한 에이전틱 AI 시스템 구축이진형 (Engineer)20:00 ~ 20:25Copilot Studio를 활용한 AI 시스템 구축유현아 (IT Content Creator)20:30 ~ 20:55AutoGen을 활용한 기업을 위한 멀티에이전트 구축정원석 (AI 연구원)15:00 ~ 15:25 LangGraph를 활용한 멀티에이전트 협업 네트워크 시스템 구축 (이경록, 브레인크루)15:30 ~ 15:55 어시웍스를 활용한 에이전틱AI 시스템 구축 (김태영, 인공지능팩토리)16:00 ~ 16:25 PydanticAI를 활용한 시스템 구축 방법 (허정준, Engineer)16:30 ~ 16:55 에이전틱 AI가 가져올 검색의 미래 (백승윤, Engineer)17:00 ~ 17:25 OpenAI Swarm를 활용한 AI 협업 시스템 구축 (서호건, 한국원자력연구원)17:30 ~ 17:55 에이전틱 서치 시스템 구축 | 높아진 Autonomy Level을 중심으로 (허훈, Engineer)18:30 ~ 18:55 에이전틱 AI와 생산성의 미래 (설지원, Engineer)19:00 ~ 19:25 Microsoft Magentic-One를 활용한 시스템 구축 (윤성재, AI 컨설턴트)19:30 ~ 19:55 CrewAI를 활용한 에이전틱AI 시스템 구축 (이진형 | Engineer)20:00 ~ 20:25 Copilot Studio를 활용한 AI 시스템 구축 (유현아, IT Content Creator)20:30 ~ 20:55 AutoGen를 활용한 기업을 위한 멀티에이전트 구축 (정원석, AI 연구원)🔥 참가자들의 열정, 그 자체!📚 오후 3시부터 밤 9시까지, 쉬는 시간 없이 풀 집중 모드! 모두가 열정적으로 지식을 공유하고, 배우고, 토론한 정말 뜻깊은 시간이었습니다! 다음에는 네트워킹 시간과 저녁 시간도 추가하겠습니다.😆 📸 마지막까지 남아 체인을 상징하는 포즈로 단체 사진도 찍었습니다! 📷💪 랭체인코리아 오거나이저 팀🎤 본 행사를 사전에 기획, 준비, 운영한 랭체인코리아 오거나이저 팀(왼쪽부터 김태영, 장서연, 이지석, 유현아, 전미정)입니다! 👏 앞으로도 랭체인코리아 커뮤니티에 많은 관심과 사랑 부탁드립니다!📢 다음 밋업도 기대해 주세요! 🚀더욱 유익한 콘텐츠와 네트워킹 기회로 다시 찾아뵙겠습니다! 감사합니다! 🙌💙📢 발표자료 및 녹화영상 안내 🎥📑조만간 참가자분들에게 발표자료 및 녹화영상에 대한 안내가 나갈 예정이니 기다려주세요! ⏳📩 잊지 않고 공유해 드릴 테니 많은 기대 부탁드립니다! 🚀✨
OpenAI의 ChatCompletion API에서 Function Calling(함수 호출) 기능을 통해 모델이 스스로 적절한 함수를 선택하고, 필요한 인자를 구성하여 호출할 수 있게 되었습니다. 기존에는 모델의 답변을 파싱하여 사용자가 직접 “필요한 정보를 추출”하곤 했지만, 이제는 모델이 명시적으로 “특정 함수”를 호출하고, 그 결과를 받아 다음 문맥에 활용할 수 있습니다.이 글에서는 a부터 z까지 총 26개의 함수가 서로 의존성을 갖는 예시를 통해, Function Calling을 어떻게 구성할 수 있는지 살펴보겠습니다. 각 함수는 이전 함수가 만들어낸 “토큰”을 입력받아 새로운 “토큰”을 생성하고, 마지막에 a_func가 최종 결과를 만들어내는 구조입니다.1. 시나리오: a_func를 호출하기 위해 z_func부터 차례대로 호출예시 상황은 다음과 같습니다.z_func: 의존성이 전혀 없는 함수. 내부적으로 "z"라는 토큰을 만듦y_func: z_token을 받아서 "y" + z_token을 리턴x_func: y_token → "x" + y_token…b_func: c_token → "b" + c_tokena_func: b_token → "a" + b_token (최종 결과)사용자는 “A 함수를 호출해”라고만 말해도, 모델은 z_func → y_func → x_func → ... → b_func → a_func 순으로 호출해야 한다는 사실을 인식하고, 중간 단계 함수들을 모두 호출할 수 있습니다.2. 전체 예시 코드아래 코드에서는:z_func ~ a_func: 파이썬 상의 실제 함수들(문자열을 이어붙이는 단순 예시)tools: OpenAI에 노출할 함수의 정의(각 함수 이름, 설명, 파라미터 스키마)toolkits: 함수 이름과 실제 파이썬 함수의 매핑openai_llm(...): ChatCompletion API를 호출하고, 모델이 함수 호출을 요청하면 실제로 파이썬 함수를 실행하여 결과를 다시 모델에게 전달(while 루프로 재시도)코드 전문<code class="language-python"># -*- coding: utf-8 -*- """ function_calling_demo.py OpenAI의 Function Calling 기능을 활용해, a_func부터 z_func까지 26개의 함수가 서로 의존성을 가지도록 구성한 예시 코드. '도구(tools)' 정의를 통해 모델이 필요할 때 각 함수를 호출하고, 함수 결과를 다시 모델에 전달하는 과정을 반복하여 최종 값을 얻는다. """ from openai import OpenAI import requests import json import yfinance as yf ######################################## # 1. OpenAI 클라이언트 초기화 ######################################## client = OpenAI( api_key="sk-p..." ) ######################################## # 2. a~z 함수 정의 # - z_func: 의존성 없는 가장 기초 # - y_func: z_token 필요 # - ... # - a_func: b_token 필요(최종) # # 실제 로직(토큰 생성 등)은 단순히 문자열을 이어붙이는 것으로 예시 구성 ######################################## def z_func(): """z_func: 의존성 없음, 결과로 'z'를 리턴""" return "z" def y_func(z_token): """y_func: z_token -> 'y' + z_token""" return "y" + z_token def x_func(y_token): """x_func: y_token -> 'x' + y_token""" return "x" + y_token def w_func(x_token): """w_func: x_token -> 'w' + x_token""" return "w" + x_token def v_func(w_token): """v_func: w_token -> 'v' + w_token""" return "v" + w_token def u_func(v_token): """u_func: v_token -> 'u' + v_token""" return "u" + v_token def t_func(u_token): """t_func: u_token -> 't' + u_token""" return "t" + u_token def s_func(t_token): """s_func: t_token -> 's' + t_token""" return "s" + t_token def r_func(s_token): """r_func: s_token -> 'r' + s_token""" return "r" + s_token def q_func(r_token): """q_func: r_token -> 'q' + r_token""" return "q" + r_token def p_func(q_token): """p_func: q_token -> 'p' + q_token""" return "p" + q_token def o_func(p_token): """o_func: p_token -> 'o' + p_token""" return "o" + p_token def n_func(o_token): """n_func: o_token -> 'n' + o_token""" return "n" + o_token def m_func(n_token): """m_func: n_token -> 'm' + n_token""" return "m" + n_token def l_func(m_token): """l_func: m_token -> 'l' + m_token""" return "l" + m_token def k_func(l_token): """k_func: l_token -> 'k' + l_token""" return "k" + l_token def j_func(k_token): """j_func: k_token -> 'j' + k_token""" return "j" + k_token def i_func(j_token): """i_func: j_token -> 'i' + j_token""" return "i" + j_token def h_func(i_token): """h_func: i_token -> 'h' + i_token""" return "h" + i_token def g_func(h_token): """g_func: h_token -> 'g' + h_token""" return "g" + h_token def f_func(g_token): """f_func: g_token -> 'f' + g_token""" return "f" + g_token def e_func(f_token): """e_func: f_token -> 'e' + f_token""" return "e" + f_token def d_func(e_token): """d_func: e_token -> 'd' + e_token""" return "d" + e_token def c_func(d_token): """c_func: d_token -> 'c' + d_token""" return "c" + d_token def b_func(c_token): """b_func: c_token -> 'b' + c_token""" return "b" + c_token def a_func(b_token): """a_func: b_token -> 'a' + b_token (최종)""" return "a" + b_token ############################################## # 3. tools 정의 (Function Calling용 스키마) # - a~z 모든 함수를 등록하고, 각 함수에 필요한 인자와 설명을 JSON Schema로 표시 ############################################## tools = [ { "type": "function", "function": { "name": "z_func", "description": ( "Z 함수: 의존성이 없는 가장 기초 함수. 결과값으로 z_token을 " "생성한다고 가정. 다른 많은 함수들이 z_token을 필요로 할 수 있음." ), "parameters": { "type": "object", "properties": { # z_func는 인자가 없음 }, "required": [] }, }, }, { "type": "function", "function": { "name": "y_func", "description": ( "Y 함수: z_token이 필요. z_func의 결과로부터 z_token을 받아서 " "y_token을 생성한다고 가정." ), "parameters": { "type": "object", "properties": { "z_token": { "type": "string", "description": "z_func 호출 결과로 얻은 토큰" } }, "required": ["z_token"] }, }, }, { "type": "function", "function": { "name": "x_func", "description": ( "X 함수: y_token이 필요. y_func의 결과로부터 y_token을 받아서 " "x_token을 생성한다고 가정." ), "parameters": { "type": "object", "properties": { "y_token": { "type": "string", "description": "y_func 호출 결과로 얻은 토큰" } }, "required": ["y_token"] }, }, }, { "type": "function", "function": { "name": "w_func", "description": "W 함수: x_token 필요, 결과로 w_token을 만든다고 가정.", "parameters": { "type": "object", "properties": { "x_token": { "type": "string", "description": "x_func 호출 결과로 얻은 토큰" } }, "required": ["x_token"] }, }, }, { "type": "function", "function": { "name": "v_func", "description": "V 함수: w_token 필요, 결과로 v_token을 만든다고 가정.", "parameters": { "type": "object", "properties": { "w_token": { "type": "string", "description": "w_func 호출 결과로 얻은 토큰" } }, "required": ["w_token"] }, }, }, { "type": "function", "function": { "name": "u_func", "description": "U 함수: v_token 필요, 결과로 u_token을 만든다고 가정.", "parameters": { "type": "object", "properties": { "v_token": { "type": "string", "description": "v_func 호출 결과로 얻은 토큰" } }, "required": ["v_token"] }, }, }, { "type": "function", "function": { "name": "t_func", "description": "T 함수: u_token 필요, 결과로 t_token을 만든다고 가정.", "parameters": { "type": "object", "properties": { "u_token": { "type": "string", "description": "u_func 호출 결과로 얻은 토큰" } }, "required": ["u_token"] }, }, }, { "type": "function", "function": { "name": "s_func", "description": "S 함수: t_token 필요, 결과로 s_token을 만든다고 가정.", "parameters": { "type": "object", "properties": { "t_token": { "type": "string", "description": "t_func 호출 결과로 얻은 토큰" } }, "required": ["t_token"] }, }, }, { "type": "function", "function": { "name": "r_func", "description": "R 함수: s_token 필요, 결과로 r_token을 만든다고 가정.", "parameters": { "type": "object", "properties": { "s_token": { "type": "string", "description": "s_func 호출 결과로 얻은 토큰" } }, "required": ["s_token"] }, }, }, { "type": "function", "function": { "name": "q_func", "description": "Q 함수: r_token 필요, 결과로 q_token을 만든다고 가정.", "parameters": { "type": "object", "properties": { "r_token": { "type": "string", "description": "r_func 호출 결과로 얻은 토큰" } }, "required": ["r_token"] }, }, }, { "type": "function", "function": { "name": "p_func", "description": "P 함수: q_token 필요, 결과로 p_token을 만든다고 가정.", "parameters": { "type": "object", "properties": { "q_token": { "type": "string", "description": "q_func 호출 결과로 얻은 토큰" } }, "required": ["q_token"] }, }, }, { "type": "function", "function": { "name": "o_func", "description": "O 함수: p_token 필요, 결과로 o_token을 만든다고 가정.", "parameters": { "type": "object", "properties": { "p_token": { "type": "string", "description": "p_func 호출 결과로 얻은 토큰" } }, "required": ["p_token"] }, }, }, { "type": "function", "function": { "name": "n_func", "description": "N 함수: o_token 필요, 결과로 n_token을 만든다고 가정.", "parameters": { "type": "object", "properties": { "o_token": { "type": "string", "description": "o_func 호출 결과로 얻은 토큰" } }, "required": ["o_token"] }, }, }, { "type": "function", "function": { "name": "m_func", "description": "M 함수: n_token 필요, 결과로 m_token을 만든다고 가정.", "parameters": { "type": "object", "properties": { "n_token": { "type": "string", "description": "n_func 호출 결과로 얻은 토큰" } }, "required": ["n_token"] }, }, }, { "type": "function", "function": { "name": "l_func", "description": "L 함수: m_token 필요, 결과로 l_token을 만든다고 가정.", "parameters": { "type": "object", "properties": { "m_token": { "type": "string", "description": "m_func 호출 결과로 얻은 토큰" } }, "required": ["m_token"] }, }, }, { "type": "function", "function": { "name": "k_func", "description": "K 함수: l_token 필요, 결과로 k_token을 만든다고 가정.", "parameters": { "type": "object", "properties": { "l_token": { "type": "string", "description": "l_func 호출 결과로 얻은 토큰" } }, "required": ["l_token"] }, }, }, { "type": "function", "function": { "name": "j_func", "description": "J 함수: k_token 필요, 결과로 j_token을 만든다고 가정.", "parameters": { "type": "object", "properties": { "k_token": { "type": "string", "description": "k_func 호출 결과로 얻은 토큰" } }, "required": ["k_token"] }, }, }, { "type": "function", "function": { "name": "i_func", "description": "I 함수: j_token 필요, 결과로 i_token을 만든다고 가정.", "parameters": { "type": "object", "properties": { "j_token": { "type": "string", "description": "j_func 호출 결과로 얻은 토큰" } }, "required": ["j_token"] }, }, }, { "type": "function", "function": { "name": "h_func", "description": "H 함수: i_token 필요, 결과로 h_token을 만든다고 가정.", "parameters": { "type": "object", "properties": { "i_token": { "type": "string", "description": "i_func 호출 결과로 얻은 토큰" } }, "required": ["i_token"] }, }, }, { "type": "function", "function": { "name": "g_func", "description": "G 함수: h_token 필요, 결과로 g_token을 만든다고 가정.", "parameters": { "type": "object", "properties": { "h_token": { "type": "string", "description": "h_func 호출 결과로 얻은 토큰" } }, "required": ["h_token"] }, }, }, { "type": "function", "function": { "name": "f_func", "description": "F 함수: g_token 필요, 결과로 f_token을 만든다고 가정.", "parameters": { "type": "object", "properties": { "g_token": { "type": "string", "description": "g_func 호출 결과로 얻은 토큰" } }, "required": ["g_token"] }, }, }, { "type": "function", "function": { "name": "e_func", "description": "E 함수: f_token 필요, 결과로 e_token을 만든다고 가정.", "parameters": { "type": "object", "properties": { "f_token": { "type": "string", "description": "f_func 호출 결과로 얻은 토큰" } }, "required": ["f_token"] }, }, }, { "type": "function", "function": { "name": "d_func", "description": "D 함수: e_token 필요, 결과로 d_token을 만든다고 가정.", "parameters": { "type": "object", "properties": { "e_token": { "type": "string", "description": "e_func 호출 결과로 얻은 토큰" } }, "required": ["e_token"] }, }, }, { "type": "function", "function": { "name": "c_func", "description": "C 함수: d_token 필요, 결과로 c_token을 만든다고 가정.", "parameters": { "type": "object", "properties": { "d_token": { "type": "string", "description": "d_func 호출 결과로 얻은 토큰" } }, "required": ["d_token"] }, }, }, { "type": "function", "function": { "name": "b_func", "description": "B 함수: c_token 필요, 결과로 b_token을 만든다고 가정.", "parameters": { "type": "object", "properties": { "c_token": { "type": "string", "description": "c_func 호출 결과로 얻은 토큰" } }, "required": ["c_token"] }, }, }, { "type": "function", "function": { "name": "a_func", "description": ( "A 함수: b_token이 필요. b_func 호출 결과로 b_token을 받고, " "최종 결과를 생성한다고 가정." ), "parameters": { "type": "object", "properties": { "b_token": { "type": "string", "description": "b_func 호출 결과로 얻은 토큰" } }, "required": ["b_token"] }, }, } ] ############################################## # 4. 실제 Python 함수(코드)와 tool name 매핑 ############################################## toolkits = { "z_func": z_func, "y_func": y_func, "x_func": x_func, "w_func": w_func, "v_func": v_func, "u_func": u_func, "t_func": t_func, "s_func": s_func, "r_func": r_func, "q_func": q_func, "p_func": p_func, "o_func": o_func, "n_func": n_func, "m_func": m_func, "l_func": l_func, "k_func": k_func, "j_func": j_func, "i_func": i_func, "h_func": h_func, "g_func": g_func, "f_func": f_func, "e_func": e_func, "d_func": d_func, "c_func": c_func, "b_func": b_func, "a_func": a_func, } ######################################## # 5. 시스템 메시지 # - 모델에게 "알아서 필요한 함수는 호출하라" 고 지시 ######################################## system_prompt = """ You are a helpful assistant. Write in Korean. You have access to the following tools. If the user asks for something that requires calling a function, call it with the correct arguments. Otherwise, respond directly in natural language. """ ######################################## # 6. 대화(챗) + 함수 호출 로직 ######################################## def openai_llm(user_input, chat_history): """ - chat_history에 대화 내용(system, user, assistant, tool 등)을 순차적으로 기록 - 모델에게 질의 후, 만약 tool_calls가 있으면 해당 함수를 실제로 호출하고, 그 결과를 tool 메시지로 추가 - 다시 모델에게 재요청을 반복하여, 함수 호출이 더 이상 없을 때 최종 답변을 반환 """ # 최초 대화에 system 메시지를 넣음 if len(chat_history) == 0: chat_history.append({"role": "system", "content": system_prompt}) # 사용자 메시지를 추가 chat_history.append({"role": "user", "content": user_input}) # 함수 호출이 없을 때까지 반복 while True: # 1) OpenAI ChatCompletion 요청 completion = client.chat.completions.create( model="gpt-4o", # 예시 모델 messages=chat_history, tools=tools ) # 모델이 생성한 assistant 메시지를 획득 assistant_msg = completion.choices[0].message # assistant_msg를 대화 기록에 추가 chat_history.append(assistant_msg) # 2) 모델이 함수 호출을 했는지 (tool_calls) 확인 if not hasattr(assistant_msg, "tool_calls") or not assistant_msg.tool_calls: # 함수 호출이 없으면 일반 답변으로 간주, while 종료 break # 3) 함수 호출이 있을 경우 -> 실제 파이썬 함수를 호출 for tool_call in assistant_msg.tool_calls: fn_name = tool_call.function.name fn_args_str = tool_call.function.arguments # 함수 인자를 JSON 디코딩 fn_args = json.loads(fn_args_str) if fn_args_str else {} print(fn_name, fn_args_str) # 디버그 출력 (어떤 함수가 어떻게 호출되는지) # 실제 함수 실행 result = toolkits[fn_name](**fn_args) # 실행 결과를 role="tool" 메시지로 추가 tool_message = { "role": "tool", "tool_call_id": tool_call.id, "content": result } chat_history.append(tool_message) # 4) tool 메시지를 추가한 뒤, while 루프를 반복하여 # 모델이 다시 한 번(또는 여러 번) 함수 호출할지 확인 # 없으면 break # 함수 호출이 없을 때(while 탈출 시), 최종적으로 assistant_msg.content 리턴 return assistant_msg.content ######################################## # 7. 실행 예시 ######################################## if __name__ == "__main__": # 첫 테스트: "A 함수를 호출해"라고 요청해보기 # 모델이 z부터 b까지 차례로 호출 후 최종적으로 a_func를 호출하는지 확인 answer = openai_llm("A 함수를 호출해", []) print("A I >", answer) # 대화 루프 예시 # - 사용자가 원하는 요청을 입력하면, 모델이 # 필요한 함수를 순차적으로 호출할 수 있음 chat_history = [] while True: user_input = input("\nUSER> ") if user_input.lower() == "quit": break ai_response = openai_llm(user_input, chat_history) print(f"A I> {ai_response}")</code>3. 동작 확인예시로, “A 함수를 호출해”라고 입력하면, 콘솔에 함수 호출 과정이 순서대로 찍히고, 최종적으로 “a_func”가 호출된 결과(문자열 "abcdefghijklmnopqrstuvwxyz" 등)가 출력됩니다. 실제로는 모델이 단계마다 z_func를 호출하여 "z" 토큰을 만들고, y_func(z_token="z")를 호출해 "yz"를 만든 뒤, x_func(y_token="yz")를 호출해 "xyz" … 이런 식으로 중간 함수 결과를 축적합니다.콘솔 로그:4. 정리 및 활용 아이디어Function Calling을 통해, 단순 “모델 출력 파싱” 과정을 자동화복잡한 함수 간 의존이 있어도, 모델이 “먼저 필요한 정보를 얻기 위한 함수 → 후속 함수” 순으로 여러 번 호출 가능실제로는 사내 API, DB, 외부 API 등을 호출하여 다양한 작업을 수행할 수 있음함수 개수가 많을수록(10~20개 이상) 모델이 올바른 함수를 찾기 어려울 수 있으므로, 함수명을 직관적으로 지어주고, 시스템 메시지나 함수 description에서 활용 맥락을 자세히 안내해주면 좋습니다.이로써, 서로 의존관계를 가지는 다수의 함수를 OpenAI Function Calling으로 유연하게 구성하는 방법을 살펴봤습니다. ReferenceOpenAI Function Calling 문서OpenAI Cookbook: How to call functions with chat models