또는, watsonx.ai 의 그래픽 도구를 사용하여 에이전트를 만들 수 있습니다. 에이전트 랩을 참조하십시오.
개요
Copy link to section
에이전트 애플리케이션을 사용하면 파운데이션 모델이 사용자와의 상호 작용 흐름을 제어하는 에이전트 역할을 할 수 있습니다. 기초 모델이 사용할 수 있는 도구를 포함하여 상호 작용의 매개 변수를 정의하지만, 기초 모델이 상호 작용의 현재 상태에 따라 차선책을 결정하도록 허용합니다. 도구 호출을 함수 호출이라고도 합니다.
실제 워크플로에서는 모든 상호작용을 시작할 때 항상 하나의 도구를 호출하는 것이 좋습니다. 나중에 교환에서 사용자가 작업에 대한 후속 질문에 어떻게 대답하는지에 따라 다른 프롬프트를 사용할 수 있습니다. 또는 워크플로우를 완료하는 데 필요한 다양한 타사 도구를 호출할 수도 있습니다. 이러한 옵션을 정의한 다음 파운데이션 모델이 적절한 시점에 반환할 프롬프트 또는 사용할 도구를 선택하도록 할 수 있습니다.
예를 들어 레스토랑 예약 앱에서 다음 정보를 수집한 다음 예약을 생성해야 할 수 있습니다:
위치
게스트 수
날짜 및 시간
정보가 수집되는 순서는 테이블당 수용 인원이 제한되어 있거나 날씨가 좋은 날 야외에 더 많은 좌석이 있는 일부 장소에서만 중요할 수 있습니다. 코드에서 이러한 조건을 고려하여 상담원이 예약 요청을 완료하기 전에 타사 날씨 앱과 같은 추가 도구를 호출할 시기를 재단 모델이 결정하도록 할 수 있습니다.
지원되는 파운데이션 모델
Copy link to section
상담원 워크플로우를 구축할 때는 다음 요구 사항을 충족하는 기본 모델을 선택하세요:
채팅 작업 처리
도구 호출 지원
다음 작업을 선택할 수 있습니다
채팅 API에서 도구 호출을 지원하는 기초 모델 목록을 프로그래밍 방식으로 가져오려면 사용 가능한 기초 모델 목록 메서드 요청을 제출할 때 filters=task_function_calling 매개변수를 지정하세요.
다음 예제에서는 덧셈 함수와 곱셈 함수라는 두 가지 도구를 정의합니다. 이 예에서는 사용자 입력을 기초 모델에 제출하고 모델이 질문에 답하는 데 사용할 도구를 선택할 수 있도록 합니다.
다음 예제에서는 ' {url} 변수를 ' us-south.ml.cloud.ibm.com 와 같이 인스턴스에 적합한 값으로 바꿉니다. 나만의 무기명 토큰과 프로젝트 ID를 추가하세요.
curl -X POST \
'https://{url}/ml/v1/text/chat?version=2024-10-08' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJraWQiOi...'
--data '{"model_id":"mistralai/mistral-large","project_id":"4947c695-a374-428c-acca-332c1a1dc9e9","messages":[{"role":"user","content":[{"type":"text","text":"What is 2 plus 4?"}]}],"tools":[{"type":"function","function":{"name":"add","description":"Adds the values a and b to get a sum.","parameters":{"type":"object","properties":{"a":{"description":"A number value","type":"float"},"b":{"description":"A number value","type":"float"}},"required":["a","b"]}}},{"type":"function","function":{"name":"multiply","description":"Multiplies the values a and b.","parameters":{"type":"object","properties":{"a":{"description":"A number value","type":"float"},"b":{"description":"A number value","type":"float"}},"required":["a","b"]}}}],"tool_choice_option":"auto","max_tokens":300,"time_limit":1000}'
Copy to clipboard클립보드에 복사됨Show more
샘플 출력은 모델(이 경우 mistral-large )이 작업에 사용할 올바른 도구인 ' add 함수를 선택할 수 있음을 보여줍니다.
{"id":"chatcmpl-2f47da4026950db321698cb733b25e89","model_id":"mistralai/mistral-large","model":"mistralai/mistral-large","choices":[{"index":0,"message":{"role":"assistant","tool_calls":[{"id":"H6KoCbaZV","type":"function","function":{"name":"add","arguments":"{\"a\": 2, \"b\": 4}"}}]},"finish_reason":"tool_calls"}],"created":1739311926,"model_version":"2.0.0","created_at":"2025-02-11T22:12:07.243Z","usage":{"completion_tokens":25,"prompt_tokens":189,"total_tokens":214},"system":{"warnings":[{"message":"This model is a Non-IBM Product governed by a third-party license that may impose use restrictions and other obligations. By using this model you agree to its terms as identified in the following URL.","id":"disclaimer_warning","more_info":"https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-models.html?context=wx"}]}}
Copy to clipboard클립보드에 복사됨Show more
granite-3-2b-instruct 사용한 도구 호출 요청 예시
Copy link to section
다음 요청은 덧셈 함수와 곱셈 함수라는 두 가지 도구를 정의하고 granite-3-2b-instruct 기초 모델에 어떤 도구를 사용할지 묻습니다.
Granite 모델은 요청과 함께 시스템 프롬프트를 제공하면 도구를 더 잘 호출할 수 있습니다. 다음과 같은 시스템 프롬프트가 사용됩니다:
IBM 개발한 Granite 입니다. 당신은 다음과 같은 도구에 접근할 수 있는 유용한 AI 비서입니다. 사용자의 질문에 답변하기 위해 도구가 필요한 경우, <|tool_call|>를 입력한 다음, 사용된 도구의 JSON 목록을 입력하십시오. 제공된 도구 목록에 해당 도구가 없는 경우, 요청을 이행할 능력이 없다는 사실을 사용자에게 알리십시오.
다음 예제에서는 ' {url} 변수를 ' us-south.ml.cloud.ibm.com 와 같이 인스턴스에 적합한 값으로 바꿉니다. 나만의 무기명 토큰과 프로젝트 ID를 추가하세요.
{"model_id":"ibm/granite-3-2b-instruct","project_id":"4947c695-a374-428c-acca-332c1a1dc9e9","messages":[{"role":"system","content":[{"type":"text","text":"You are Granite, developed by IBM. You are a helpful AI assistant with access to the following tools. When a tool is required to answer the user's query, respond with <|tool_call|> followed by a JSON list of tools used. If a tool does not exist in the provided list of tools, notify the user that you do not have the ability to fulfill the request."}]},{"role":"user","content":[{"type":"text","text":"What is 2 times 4?"}]}],"tools":[{"type":"function","function":{"name":"add","description":"Adds the values a and b to get a sum.","parameters":{"type":"object","properties":{"a":{"description":"A number value","type":"float"},"b":{"description":"A number value","type":"float"}},"required":["a","b"]}}},{"type":"function","function":{"name":"multiply","description":"Multiplies the values a and b.","parameters":{"type":"object","properties":{"a":{"description":"A number value","type":"float"},"b":{"description":"A number value","type":"float"}},"required":["a","b"]}}}],"tool_choice_option":"auto","max_tokens":300,"time_limit":10000}
Copy to clipboard클립보드에 복사됨Show more
granite-3-2b-instruct 파운데이션 모델은 쿼리에 대한 올바른 도구를 선택할 수 있습니다.