# ollama, 도구 호출 기능(tool support) 추가

**URL:** <https://discuss.pytorch.kr/t/ollama-tool-support/5072>\
**Category:** 읽을거리&정보공유\
**Tags:** ollama, llm-tool-usage, api-tool-use, tool-for-llm, tool-support\
**Created:** [8월 20, 2024, 10:04오후 UTC](https://discuss.pytorch.kr/t/ollama-tool-support/5072 "2024-08-20T22:04:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![9bow](https://discuss.pytorch.kr/user_avatar/discuss.pytorch.kr/9bow/32/16301_2.png) [@9bow](https://discuss.pytorch.kr/u/9bow)\
**Post date:** [8월 20, 2024, 10:04오후 UTC](https://discuss.pytorch.kr/t/ollama-tool-support/5072/1 "2024-08-20T22:04:34Z")

</div>

## ollama의 tool support 기능 소개

 ![ollama, 도구 호출 기능(tool support) 추가](https://discuss.pytorch.kr/uploads/default/original/2X/2/275343e72504de944c9e1bdffbc38369b591f33a.jpeg)

Ollama는 이제 Llama 3.1과 같은 인기 모델과 함께 도구 호출을 지원합니다. 이를 통해 모델이 주어진 프롬프트에 대해 알고 있는 도구를 사용하여 더 복잡한 작업을 수행하거나 외부 세계와 상호작용할 수 있습니다. 예를 들어, 다음과 같은 도구들을 사용할 수 있습니다:

- 함수와 API 호출(Functions and APIs)
- 웹 브라우징 (Web browsing)
- 코드 해석기 (Code interpreter)
- 기타 다양한 도구들

[https://github.com/user-attachments/assets/aea4d7c1-f1be-41fd-9077-023d37a9d052](https://github.com/user-attachments/assets/aea4d7c1-f1be-41fd-9077-023d37a9d052)

## 도구 호출 예시

도구 호출을 활성화하려면 Ollama의 API에서 `tools` 필드를 통해 사용 가능한 도구 목록을 제공해야 합니다. 아래는 예시 코드입니다:

```python
import ollama

response = ollama.chat(
    model='llama3.1',
    messages=[{'role': 'user', 'content': 'What is the weather in Toronto?'}],
    tools=[{
        'type': 'function',
        'function': {
            'name': 'get_current_weather',
            'description': 'Get the current weather for a city',
            'parameters': {
                'type': 'object',
                'properties': {
                    'city': {
                        'type': 'string',
                        'description': 'The name of the city',
                    },
                },
                'required': ['city'],
            },
        },
    }],
)
print(response['message']['tool_calls'])

```

도구 호출 기능을 지원하는 모델은 `tool_calls` 응답과 함께 도구를 사용하여 대답할 수 있습니다. 도구 응답은 `tool` 역할을 가진 메시지를 통해 제공될 수 있습니다. 자세한 내용은 [Ollama의 API 문서](https://github.com/ollama/ollama/blob/main/docs/api.md#chat-request-with-tools)를 참조하세요. 또한, Ollama의 OpenAI 호환 엔드포인트에서도 도구 호출 기능을 지원합니다.

도구 호출 기능을 지원하는 모델의 목록은 [모델 페이지의 Tools 카테고리](https://ollama.com/search?c=tools)에서 확인할 수 있습니다. 현재까지 아래 모델들이 도구 호출 기능을 제공합니다:

- [Llama 3.1](https://ollama.com/library/llama3.1)
- [Mistral Nemo](https://ollama.com/library/mistral-nemo)
- [Firefunction v2](https://ollama.com/library/firefunction-v2)
- [Command-R +](https://ollama.com/library/command-r-plus)

 ![ollama의 도구 호출 기능(tool support) 지원 모델 목록](https://discuss.pytorch.kr/uploads/default/original/2X/8/80d2de5c7937f993dddd3190071c69616fd080c0.jpeg)

## 🦙 도구 호출 기능 공지 블로그

> **[Tool support · Ollama Blog](https://ollama.com/blog/tool-support)**
>
> Ollama now supports tool calling with popular models such as Llama 3.1. This enables a model to answer a given prompt using tool(s) it knows about, making it possible for models to perform more complex tasks or interact with the outside world.

## 📦 도구 호출 기능을 지원하는 모델 목록

> **[Tools models · Ollama](https://ollama.com/search?c=tools)**
>
> Tools models on Ollama.

## 🖼 도구 호출 기능 사용을 위한 예시 코드

- Python 예제: [https://github.com/ollama/ollama-python/blob/main/examples/tools/main.py](https://github.com/ollama/ollama-python/blob/main/examples/tools/main.py)

- JavaScript(TypeScript) 예제: [https://github.com/ollama/ollama-js/blob/main/examples/tools/tools.ts](https://github.com/ollama/ollama-js/blob/main/examples/tools/tools.ts)

* * *

_이 글은 GPT 모델로 정리한 글을 바탕으로 한 것으로, 원문의 내용 또는 의도와 다르게 정리된 내용이 있을 수 있습니다. 관심있는 내용이시라면 원문도 함께 참고해주세요! 읽으시면서 어색하거나 잘못된 내용을 발견하시면 덧글로 알려주시기를 부탁드립니다._ 🤗

[:pytorch:파이토치 한국 사용자 모임🇰🇷](https://pytorch.kr/)이 정리한 이 글이 유용하셨나요? [회원으로 가입](https://discuss.pytorch.kr/signup)하시면 주요 글들을 이메일💌로 보내드립니다! (기본은 Weekly지만 [Daily로 변경도 가능](https://discuss.pytorch.kr/my/preferences/emails)합니다.)

🎁 아래↘쪽에 좋아요👍를 눌러주시면 새로운 소식들을 정리하고 공유하는데 힘이 됩니다~ 🤩
