Azure AI Foundry에서의 도구 사용

Azure AI Foundry에서의 도구 사용

이 페이지는 Azure AI Foundry에서 Cohere의 도구 사용(tool use)을 사용하는 방법을 설명해요. 함수 호출(function calling)을 통해 모델이 코드의 함수를 식별하고 호출하게 하는 방법을 살펴볼게요.

출처: 문서

본문

이 페이지는 Azure AI Foundry에서 Cohere의 도구 사용을 사용하는 방법을 설명해요.

도구 사용하기 (Using Tools)

함수 호출을 사용해 모델이 코드에서 함수를 식별하고 호출하도록 할 수 있어요.

Cohere SDK로 도구 사용을 하는 코드 스니펫은 다음과 같아요:

PYTHON

import cohere

co = cohere.ClientV2(
    api_key="key",
    base_url="https://your-endpoint.inference.ai.azure.com/v1/chat",
}

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Fetches the current weather for a city.",
            "parameters": {
                "type": "object",
                "properties": {
                    "city": {
                        "type": "string",
                        "description": "The city name, e.g., Toronto.",
                    },
                    "unit": {
                        "type": "string",
                        "enum": ["celsius", "fahrenheit"],
                        "description": "The temperature unit.",
                    },
                },
                "required": ["city", "unit"],
            },
        },
    },
]

response = co.chat(
    model="command-a-03-2025",
    messages=[
        {"role": "user", "content": "What is the weather in Toronto?",}
    ],
    tools=tools,
)

print(response.message.tool_calls)

Python 패키지 (Python packages)

다음 패키지가 설치되어 있는지 확인하세요:

  • azure-ai-inference
  • cohere

다음 단계 (Next Steps)

계속 탐색해 보세요:

더 알아보기 (Learn more)