Ollama ์ฌ์ฉ ์ JSON Parse error: Unexpected EOF๊ฐ ๋๋ ๋ฌธ์ ๋ฅผ ์์ธ-ํด๊ฒฐ ์์๋ก ๋ค๋ฃน๋๋ค.
๋น ๋ฅด๊ฒ ์คํ (๋ณต๋ถ)
{"provider":"ollama","model":"qwen3-coder","stream":false}
curl -s http://localhost:11434/api/chat -d ...flowchart TD A[stream=true] --> B[NDJSON] B --> C[JSON ํ์ฑ ์คํจ] C --> D[Unexpected EOF] D --> E[stream=false]
๋จ๊ณ๋ณ ์ ์ฉ
1) ์ฆ์ ํ์ธ
- ์ค๋ช : tool call ์ Unexpected EOF๊ฐ ๋ฐ์ํ๋ฉด ์ด ์ผ์ด์ค๋ฅผ ์์ฌํฉ๋๋ค.
- ์คํ ์์:
{"provider":"ollama","model":"qwen3-coder","stream":false}
2) ์์ธ ํ์
- ์ค๋ช : Ollama๋ stream=true์์ NDJSON์ ๋ฐํํ๊ณ , SDK๋ ๋จ์ผ JSON ๊ธฐ๋๋ก ํ์ฑ ์คํจํฉ๋๋ค.
- ์คํ ์์:
curl -s http://localhost:11434/api/chat -d ...
3) ์ฆ์ ํด๊ฒฐ
- ์ค๋ช : provider ์ค์ ์ stream:false๋ฅผ ์ ์ฉํฉ๋๋ค.
- ์คํ ์์:
curl -s http://localhost:11434/api/chat -d ...
4) ๊ฒ์ฆ
- ์ค๋ช : curl ํ ์คํธ๋ก tool call ์๋ต์ ํ์ธํฉ๋๋ค.
- ์คํ ์์:
curl -s http://localhost:11434/api/chat -d ...
5) ์ฅ๊ธฐ ๋์
- ์ค๋ช : SDK ์ด์ ํธ๋์ปค๋ฅผ ๊ตฌ๋ ํ๊ณ ๋ฒ์ ์ ๋ฐ์ดํธ๋ฅผ ํ์ธํฉ๋๋ค.
- ์คํ ์์:
curl -s http://localhost:11434/api/chat -d ...
๋ถ๋ก) ์๋ฌธ ์ฝ๋ ์ค๋ํซ (๊ฒ์์ฉ, ์ด๋ณด์๋ ๊ฑด๋๋ฐ๊ธฐ)
{"message":{"tool_calls":[{"function":{"name":"read","arguments":{"filePath":"README.md"}}}]}, "done":false}
{"message":{"content":""}, "done":true}{
"provider": "ollama",
"model": "qwen3-coder",
"stream": false
}# Test with curl (should work with stream: false)
curl -s http://localhost:11434/api/chat \
-d '{
"model": "qwen3-coder",
"messages": [{"role": "user", "content": "Read file README.md"}],
"stream": false,
"tools": [{"type": "function", "function": {"name": "read", "description": "Read a file", "parameters": {"type": "object", "properties": {"filePath": {"type": "string"}}, "required": ["filePath"]}}}]
}'๋ง๋ฌด๋ฆฌ ์ฒดํฌ
- ์ โ๋น ๋ฅด๊ฒ ์คํโ ๋ช ๋ น์ ์ต์ 1๊ฐ ์คํํ๋ค.
- ์คํจ ์ โ์๋ฌธ ์คํ ์ฝ๋ ํ์ฅโ์ ๊ด๋ จ ์ฝ๋๋ฅผ ์ฌ์ฉํด ์ฌ๊ฒ์ฆํ๋ค.
- ์๋ณธ ํญ๋ชฉ ๋์กฐ ์ธ๋ฑ์ค์์ ๋น ์ง ๊ธฐ๋ฅ์ด ์๋์ง ํ์ธํ๋ค.
์ถ์ฒ
- ์๋ฌธ(๋ก์ปฌ):
oh-my-opencode/docs/troubleshooting/ollama-streaming-issue.md - ์๋ฌธ(GitHub): https://github.com/code-yeongyu/oh-my-opencode/blob/dev/docs/troubleshooting/ollama-streaming-issue.md