# ollama webui

<https://github.com/ollama-webui/ollama-webui>

![](https://3379277180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MaoWGMVdC3ztoOAzHPq%2Fuploads%2Fgit-blob-97abbc8a9b6648e10a27c7e9bc26451d3d0c242f%2F2023-12-18-07-33-03.png?alt=media)

## 1. prerequisite

webui가 api호출을 ollama server에 요청하는데 ollama server가 기본적으로 외부 트래픽을 허용하지 않아서 다음처럼 수정후 실행해야한다.

* cors를 \* 로 허용
* ip 대역폭을 0.0.0.0/0 으로 허용해서 모든 트래픽 허용

````sh
실행하기전에 기존에 실행해둔  ollama api를 0.0.0.0 에서 접속이 가능하게 해야한다. 기본적으로는 localhost라는 이름만 가능하다. cors도 추가해야한다.

```sh
curl http://localhost:11434 => ok
curl http://hostname:11434  => nogood
curl http://hostip:11434    => nogood
````

```conf
export OLLAMA_HOST=0.0.0.0:11434
export OLLAMA_ORIGINS=*
ollama serve
```

### systemd에서 실행

```sh
mkdir -p /etc/systemd/system/ollama.service.d
echo '[Service]' >>/etc/systemd/system/ollama.service.d/environment.conf
echo 'Environment="OLLAMA_HOST=0.0.0.0:11434"' >>/etc/systemd/system/ollama.service.d/environment.conf
echo 'Environment="OLLAMA_ORIGINS=*"' >>/etc/systemd/system/ollama.service.d/environment.conf

systemctl daemon-reload
systemctl restart ollama

curl http://localhost:11434 => ok
curl http://hostname:11434  => ok
curl http://hostip:11434    => ok
```

## webui실행

git repo를 클론해서 build를 해도 되지만 난 소스코드를 수정할 이유가 없으므로 다음처럼 진행한다.

192.168.4.61: hostip

```sh
docker run -d -p 3000:8080 --name ollama-webui --restart always \
-e OLLAMA_API_BASE_URL='http://192.168.4.61:11434/api' \
-e PUBLIC_API_BASE_URL='http://192.168.4.61:11434/api' \
ghcr.io/ollama-webui/ollama-webui:main
```

실행해보면 화면이 잘나오고 질문에 답변이 잘 나온다.

### docker compose로 처리

```yaml
version: '3.8'
services:
  ollama-webui:
    image: ghcr.io/ollama-webui/ollama-webui:main
    container_name: ollama-webui
    ports:
      - 3000:8080
    environment:
      - 'OLLAMA_API_BASE_URL=http://192.168.4.61:11434/api'
      - 'PUBLIC_API_BASE_URL=http://192.168.4.61:11434/api'
    restart: unless-stopped
```

![](https://3379277180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MaoWGMVdC3ztoOAzHPq%2Fuploads%2Fgit-blob-7f143510998f5f0c206a51046873464f22e450f3%2F2023-12-18-07-38-42.png?alt=media)

## setting

setting메뉴를 잘 확인하자.

json으로 결과가 나오면 request mode를 json으로 바꾸면 된다.

![](https://3379277180-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MaoWGMVdC3ztoOAzHPq%2Fuploads%2Fgit-blob-22a8a293c2bf9dafea6fb7c5c936287829c6c4bd%2F2023-12-18-07-39-40.png?alt=media)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://teamsmiley.gitbook.io/devops/ai/ollama/ollama-webui.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
