help!"No valid XML" when using ollama
2025-10-31 13:26:19,732 - INFO - api.api - api.py:591 - Scanning for project cache files in: /home/tcci/.adalflow/wikicache 2025-10-31 13:26:19,736 - INFO - api.api - api.py:629 - Found 0 processed project entries. 2025-10-31 13:26:19,760 - INFO - api.api - api.py:591 - Scanning for project cache files in: /home/tcci/.adalflow/wikicache 2025-10-31 13:26:19,761 - INFO - api.api - api.py:629 - Found 0 processed project entries. 2025-10-31 13:26:20,594 - INFO - api.api - api.py:179 - Fetching model configurations 2025-10-31 13:26:20,617 - INFO - api.api - api.py:179 - Fetching model configurations 2025-10-31 13:26:28,054 - INFO - api.api - api.py:476 - Attempting to retrieve wiki cache for AsyncFuncAI/deepwiki-open (github), lang: zh 2025-10-31 13:26:28,054 - INFO - api.api - api.py:483 - Wiki cache not found for AsyncFuncAI/deepwiki-open (github), lang: zh 2025-10-31 13:26:32,214 - INFO - api.simple_chat - simple_chat.py:85 - Request size: 8755 tokens 2025-10-31 13:26:32,214 - WARNING - api.simple_chat - simple_chat.py:87 - Request exceeds recommended token limit (8755 > 7500) 2025-10-31 13:26:32,223 - INFO - api.ollama_patch - ollama_patch.py:48 - Ollama model 'nomic-embed-text' is available 2025-10-31 13:26:32,289 - INFO - adalflow.core.prompt_builder - prompt_builder.py:74 - Prompt has variables: ['schema'] 2025-10-31 13:26:32,290 - INFO - adalflow.core.prompt_builder - prompt_builder.py:74 - Prompt has variables: ['schema'] 2025-10-31 13:26:32,290 - INFO - api.rag - rag.py:74 - Dialog turns list exists but is empty 2025-10-31 13:26:32,290 - INFO - api.rag - rag.py:88 - Returning 0 dialog turns from memory 2025-10-31 13:26:32,345 - INFO - adalflow.optim.grad_component - grad_component.py:79 - EvalFnToTextLoss: No backward engine provided. Creating one using model_client and model_kwargs. 2025-10-31 13:26:32,346 - INFO - adalflow.core.generator - generator.py:188 - Generator Generator initialized. 2025-10-31 13:26:32,346 - INFO - api.data_pipeline - data_pipeline.py:780 - Preparing repo storage for https://github.com/AsyncFuncAI/deepwiki-open... 2025-10-31 13:26:32,346 - INFO - api.data_pipeline - data_pipeline.py:790 - Extracted repo name: AsyncFuncAI_deepwiki-open 2025-10-31 13:26:32,346 - INFO - api.data_pipeline - data_pipeline.py:799 - Repository already exists at /home/tcci/.adalflow/repos/AsyncFuncAI_deepwiki-open. Using existing repository. 2025-10-31 13:26:32,346 - INFO - api.data_pipeline - data_pipeline.py:813 - Repo paths: {'save_repo_dir': '/home/tcci/.adalflow/repos/AsyncFuncAI_deepwiki-open', 'save_db_file': '/home/tcci/.adalflow/databases/AsyncFuncAI_deepwiki-open.pkl'} 2025-10-31 13:26:32,346 - INFO - api.data_pipeline - data_pipeline.py:843 - Loading existing database... 2025-10-31 13:26:32,381 - INFO - adalflow.core.component - component.py:335 - Restoring class using from_dict TextSplitter, {'type': 'TextSplitter', 'data': {'_components': {'_ordered_dict': True, 'data': []}, '_parameters': {'_ordered_dict': True, 'data': []}, 'training': False, 'teacher_mode': False, 'tracing': False, 'name': 'TextSplitter', '_init_args': {'split_by': 'word', 'chunk_size': 800, 'chunk_overlap': 200, 'batch_size': 1000, 'separators': {'page': '\x0c', 'passage': '\n\n', 'word': ' ', 'sentence': '.', 'token': ''}}, 'split_by': 'word', 'separators': {'page': '\x0c', 'passage': '\n\n', 'word': ' ', 'sentence': '.', 'token': ''}, 'chunk_size': 350, 'chunk_overlap': 100, 'batch_size': 1000}} 2025-10-31 13:26:32,381 - INFO - adalflow.core.component - component.py:335 - Restoring class using from_dict OllamaDocumentProcessor, {'type': 'OllamaDocumentProcessor', 'data': {'_components': {'_ordered_dict': True, 'data': [('embedder', {'type': 'Embedder', 'data': {'_components': {'_ordered_dict': True, 'data': [('model_client', {'type': 'OllamaClient', 'data': {'_components': {'_ordered_dict': True, 'data': []}, '_parameters': {'_ordered_dict': True, 'data': []}, 'training': False, 'teacher_mode': False, 'tracing': False, 'name': 'OllamaClient', '_init_args': {'host': None}, '_host': 'http://localhost:11434', 'generate': False}})]}, '_parameters': {'_ordered_dict': True, 'data': []}, 'training': False, 'teacher_mode': False, 'tracing': False, 'name': 'Embedder', '_init_args': {'model_client': None, 'model_kwargs': {'model': 'nomic-embed-text'}, 'output_processors': None}, 'model_kwargs': {'model': 'nomic-embed-text'}, 'output_processors': None}})]}, '_parameters': {'_ordered_dict': True, 'data': []}, 'training': False, 'teacher_mode': False, 'tracing': False, 'name': 'OllamaDocumentProcessor', '_init_args': {'embedder': None}}} 2025-10-31 13:26:32,381 - INFO - adalflow.core.component - component.py:335 - Restoring class using from_dict Embedder, {'type': 'Embedder', 'data': {'_components': {'_ordered_dict': True, 'data': [('model_client', {'type': 'OllamaClient', 'data': {'_components': {'_ordered_dict': True, 'data': []}, '_parameters': {'_ordered_dict': True, 'data': []}, 'training': False, 'teacher_mode': False, 'tracing': False, 'name': 'OllamaClient', '_init_args': {'host': None}, '_host': 'http://localhost:11434', 'generate': False}})]}, '_parameters': {'_ordered_dict': True, 'data': []}, 'training': False, 'teacher_mode': False, 'tracing': False, 'name': 'Embedder', '_init_args': {'model_client': None, 'model_kwargs': {'model': 'nomic-embed-text'}, 'output_processors': None}, 'model_kwargs': {'model': 'nomic-embed-text'}, 'output_processors': None}} 2025-10-31 13:26:32,382 - INFO - adalflow.core.component - component.py:335 - Restoring class using from_dict OllamaClient, {'type': 'OllamaClient', 'data': {'_components': {'_ordered_dict': True, 'data': []}, '_parameters': {'_ordered_dict': True, 'data': []}, 'training': False, 'teacher_mode': False, 'tracing': False, 'name': 'OllamaClient', '_init_args': {'host': None}, '_host': 'http://localhost:11434', 'generate': False}} 2025-10-31 13:26:32,435 - INFO - api.data_pipeline - data_pipeline.py:848 - Loaded 978 documents from existing database 2025-10-31 13:26:32,436 - INFO - api.rag - rag.py:372 - Loaded 978 documents for retrieval 2025-10-31 13:26:32,436 - INFO - api.rag - rag.py:380 - Using 978 documents with valid embeddings for retrieval 2025-10-31 13:26:32,436 - INFO - adalflow.optim.grad_component - grad_component.py:79 - EvalFnToTextLoss: No backward engine provided. Creating one using model_client and model_kwargs. 2025-10-31 13:26:32,456 - WARNING - adalflow.components.retriever.faiss_retriever - faiss_retriever.py:191 - Embeddings are not normalized, normalizing the embeddings 2025-10-31 13:26:32,460 - INFO - adalflow.components.retriever.faiss_retriever - faiss_retriever.py:197 - Index built with 978 chunks 2025-10-31 13:26:32,460 - INFO - api.rag - rag.py:391 - FAISS retriever created successfully 2025-10-31 13:26:32,460 - INFO - api.simple_chat - simple_chat.py:114 - Retriever prepared for https://github.com/AsyncFuncAI/deepwiki-open 2025-10-31 13:26:32,460 - INFO - api.rag - rag.py:74 - Dialog turns list exists but is empty 2025-10-31 13:26:32,460 - INFO - api.rag - rag.py:88 - Returning 0 dialog turns from memory 2025-10-31 13:26:32,460 - INFO - api.simple_chat - simple_chat.py:324 - No context available from RAG 2025-10-31 13:27:43,401 - INFO - httpx - _client.py:1786 - HTTP Request: POST http://localhost:11434/api/chat "HTTP/1.1 200 OK"
same
same
wikicache not created.
2025-11-05 11:03:05,974 - INFO - api.websocket_wiki - websocket_wiki.py:202 - Retrieved 20 documents
2025-11-05 11:03:05,977 - INFO - api.rag - rag.py:74 - Dialog turns list exists but is empty
2025-11-05 11:03:06,066 - INFO - api.rag - rag.py:88 - Returning 0 dialog turns from memory
2025-11-05 11:03:06,075 - DEBUG - adalflow.components.model_client.ollama_client - ollama_client.py:308 - Using host: http://localhost:11434
2025-11-05 11:03:09,540 - DEBUG - httpcore.connection - _trace.py:87 - connect_tcp.started host='127.0.0.1' port=7890 local_address=None timeout=None socket_options=None
INFO: 127.0.0.1:55929 - "GET /auth/status HTTP/1.1" 200 OK
INFO: 127.0.0.1:62161 - "GET /auth/status HTTP/1.1" 200 OK
2025-11-05 11:03:09,545 - DEBUG - httpcore.connection - _trace.py:87 - connect_tcp.complete return_value=<httpcore._backends.anyio.AnyIOStream object at 0x000001BEB6F19E20>
2025-11-05 11:03:09,546 - DEBUG - httpcore.http11 - _trace.py:87 - send_request_headers.started request=<Request [b'POST']>
2025-11-05 11:03:09,547 - DEBUG - httpcore.http11 - _trace.py:87 - send_request_headers.complete
2025-11-05 11:03:09,547 - DEBUG - httpcore.http11 - _trace.py:87 - send_request_body.started request=<Request [b'POST']>
2025-11-05 11:03:09,548 - DEBUG - httpcore.http11 - _trace.py:87 - send_request_body.complete
2025-11-05 11:03:09,548 - DEBUG - httpcore.http11 - _trace.py:87 - receive_response_headers.started request=<Request [b'POST']>
2025-11-05 11:03:13,923 - DEBUG - httpcore.http11 - _trace.py:87 - receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'Connection', b'close'), (b'Transfer-Encoding', b'chunked'), (b'Content-Type', b'application/x-ndjson'), (b'Date', b'Wed, 05 Nov 2025 03:03:13 GMT')])
2025-11-05 11:03:13,923 - INFO - httpx - _client.py:1740 - HTTP Request: POST http://localhost:11434/api/chat "HTTP/1.1 200 OK"
2025-11-05 11:03:13,923 - DEBUG - httpcore.http11 - _trace.py:87 - receive_response_body.started request=<Request [b'POST']>
2025-11-05 11:03:46,984 - DEBUG - httpcore.http11 - _trace.py:87 - receive_response_body.complete
2025-11-05 11:03:46,984 - DEBUG - httpcore.http11 - _trace.py:87 - response_closed.started
2025-11-05 11:03:46,985 - DEBUG - httpcore.http11 - _trace.py:87 - response_closed.complete
I get the same problem.
same
- Currently, I've solved the problem. First, if you're using it in a container or Kubernetes, you need to pay attention to the UI WebSocket address.
- Second, you need to modify the code in the api/websocket_wiki.py file where it says request.provider equals "ollama".
But it's still in the testing phase currently.
if request.provider == "ollama":
# Get the response and handle it properly using the previously created api_kwargs
response = await model.acall(api_kwargs=api_kwargs, model_type=ModelType.LLM)
# Handle streaming response from Ollama
async for chunk in response:
text = None
if isinstance(chunk, dict):
text = chunk.get("message", {}).get("content") if isinstance(chunk.get("message"), dict) else chunk.get("message")
else:
message = getattr(chunk, "message", None)
if message is not None:
if isinstance(message, dict):
text = message.get("content")
else:
text = getattr(message, "content", None)
if not text:
text = getattr(chunk, 'response', None) or getattr(chunk, 'text', None)
if not text and hasattr(chunk, "__dict__"):
message = chunk.__dict__.get("message")
if isinstance(message, dict):
text = message.get("content")
if isinstance(text, str) and text and not text.startswith('model=') and not text.startswith('created_at='):
clean_text = text.replace('<think>', '').replace('</think>', '')
await websocket.send_text(clean_text)
# Explicitly close the WebSocket connection after the response is complete
await websocket.close()
我也遇到相同的问题了,不懂如何解决
我也遇到相同的问题了,不懂如何解决
试一下我的法子那
我没用ollama,直接按官网的文档部署的docker 的。也是这个提示呢,
- Currently, I've solved the problem. First, if you're using it in a container or Kubernetes, you need to pay attention to the UI WebSocket address.
- Second, you need to modify the code in the api/websocket_wiki.py file where it says request.provider equals "ollama".
But it's still in the testing phase currently.
if request.provider == "ollama": # Get the response and handle it properly using the previously created api_kwargs response = await model.acall(api_kwargs=api_kwargs, model_type=ModelType.LLM) # Handle streaming response from Ollama async for chunk in response: text = None if isinstance(chunk, dict): text = chunk.get("message", {}).get("content") if isinstance(chunk.get("message"), dict) else chunk.get("message") else: message = getattr(chunk, "message", None) if message is not None: if isinstance(message, dict): text = message.get("content") else: text = getattr(message, "content", None) if not text: text = getattr(chunk, 'response', None) or getattr(chunk, 'text', None) if not text and hasattr(chunk, "__dict__"): message = chunk.__dict__.get("message") if isinstance(message, dict): text = message.get("content") if isinstance(text, str) and text and not text.startswith('model=') and not text.startswith('created_at='): clean_text = text.replace('<think>', '').replace('</think>', '') await websocket.send_text(clean_text) # Explicitly close the WebSocket connection after the response is complete await websocket.close()
I made this change where i think it should be in that file (there's a couple places with if request.provider == "ollama":), but i get the same XML error. The logs don't move on from this line
2025-11-14 22:23:40,436 - INFO - httpx - _client.py:1740 - HTTP Request: POST http://192.168.1.8:11434/api/chat "HTTP/1.1 200 OK"
I can't read the chinese responses :-(
The original code:
if request.provider == "ollama":
# Get the response and handle it properly using the previously created api_kwargs
response = await model.acall(api_kwargs=api_kwargs, model_type=ModelType.LLM)
# Handle streaming response from Ollama
async for chunk in response:
text = getattr(chunk, 'response', None) or getattr(chunk, 'text', None) or str(chunk)
if text and not text.startswith('model=') and not text.startswith('created_at='):
text = text.replace('<think>', '').replace('</think>', '')
await websocket.send_text(text)
# Explicitly close the WebSocket connection after the response is complete
await websocket.close()
is the section that was replaced.
- Currently, I've solved the problem. First, if you're using it in a container or Kubernetes, you need to pay attention to the UI WebSocket address.
- Second, you need to modify the code in the api/websocket_wiki.py file where it says request.provider equals "ollama".
But it's still in the testing phase currently.
if request.provider == "ollama": # Get the response and handle it properly using the previously created api_kwargs response = await model.acall(api_kwargs=api_kwargs, model_type=ModelType.LLM) # Handle streaming response from Ollama async for chunk in response: text = None if isinstance(chunk, dict): text = chunk.get("message", {}).get("content") if isinstance(chunk.get("message"), dict) else chunk.get("message") else: message = getattr(chunk, "message", None) if message is not None: if isinstance(message, dict): text = message.get("content") else: text = getattr(message, "content", None) if not text: text = getattr(chunk, 'response', None) or getattr(chunk, 'text', None) if not text and hasattr(chunk, "__dict__"): message = chunk.__dict__.get("message") if isinstance(message, dict): text = message.get("content") if isinstance(text, str) and text and not text.startswith('model=') and not text.startswith('created_at='): clean_text = text.replace('<think>', '').replace('</think>', '') await websocket.send_text(clean_text) # Explicitly close the WebSocket connection after the response is complete await websocket.close()I made this change where i think it should be in that file (there's a couple places with if request.provider == "ollama":), but i get the same XML error. The logs don't move on from this line
2025-11-14 22:23:40,436 - INFO - httpx - _client.py:1740 - HTTP Request: POST http://192.168.1.8:11434/api/chat "HTTP/1.1 200 OK"
I can't read the chinese responses :-(
Since I’m not very familiar with Python, I only made some rough modifications, and I'm not sure whether the official team would consider this an acceptable approach. However, it’s currently working on my side. If you have any further questions, feel free to reply. I’ll do my best to help.
If the modified code runs, try executing it first. If issues still occur, check the browser’s WebSocket requests. When running inside a container, there’s a high chance the WebSocket may be connecting to the wrong address, such as localhost:8001. Make sure this address matches the actual Python service endpoint.
Hi @loon-hejw , How do i check the websocket value, and how do i change it if it is wrong?
@johnpwhite If you’re running the service using a container image, you’ll need to rebuild the frontend code. If you’re running it locally, you must manually update all default frontend URLs.
const DEFAULT_BASE_URL = process.env.SERVER_BASE_URL || 'http://localhost:8001';
The SERVER_BASE_URL environment variable does not work reliably, so the fallback value (http://localhost:8001) is often used instead.
hi @loon-hejw, I am running in a container. I replaced the code section with the above, and it still fails with the XML error message in the web GUI.
When you say rebuild, is this what you meant or do I have to do something else in the docker after changing the code?
@johnpwhite Rebuild the frontend during the image build process, then package it into the final container image.
Thanks @loon-hejw , however, I'm using the pre-built image here: ghcr.io/asyncfuncai/deepwiki-open:latest
I logged into the terminal when the image was running and changed the python file, will this not work? (it's not)
I'm techy but not that familiar with this stack, you're drip feeding information assuming I know what to do, unfortunately I don't - sorry about that. Is there a clear guide for those using the pre built image on how to fix while we wait for a formal fix and new release?
@johnpwhite Got it. I built the image myself. Previously, the image was built using docker-compose.ollama.yml, and Ollama couldn’t use the GPU. Dockerfile-react
FROM node:20-alpine AS node_base
FROM node_base AS node_deps
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci --legacy-peer-deps
FROM node_base AS node_builder
WORKDIR /app
COPY --from=node_deps /app/node_modules ./node_modules
COPY package.json package-lock.json next.config.ts tsconfig.json tailwind.config.js postcss.config.mjs ./
COPY src/ ./src/
COPY public/ ./public/
RUN NODE_ENV=production npm run build
FROM node:20-alpine
WORKDIR /app
COPY --from=node_builder /app/public ./public
COPY --from=node_builder /app/.next/standalone ./
COPY --from=node_builder /app/.next/static ./.next/static
EXPOSE 3000
CMD ["node", "server.js"]
Dockerfile-python
FROM python:3.11-slim AS py_deps
WORKDIR /api
COPY api/pyproject.toml .
COPY api/poetry.lock .
RUN poetry config installer.parallel false --local && \
poetry config virtualenvs.create true --local && \
poetry config virtualenvs.in-project true --local && \
poetry config virtualenvs.options.always-copy true --local && \
poetry source add aliyun https://mirrors.aliyun.com/pypi/simple && \
poetry lock --no-interaction --no-ansi && \
POETRY_HTTP_TIMEOUT=300 poetry install --without dev --no-interaction --no-ansi && \
poetry cache clear --all .
FROM python:3.11-slim
WORKDIR /app
RUN set -eux; \
echo "deb http://mirrors.aliyun.com/debian/ trixie main contrib non-free non-free-firmware" > /etc/apt/sources.list.d/aliyun.list; \
echo "deb http://mirrors.aliyun.com/debian/ trixie-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list.d/aliyun.list; \
echo "deb http://mirrors.aliyun.com/debian-security trixie-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list.d/aliyun.list; \
echo "deb http://mirrors.aliyun.com/debian/ trixie-backports main contrib non-free non-free-firmware" >> /etc/apt/sources.list.d/aliyun.list; \
rm -f /etc/apt/sources.list.d/debian.sources || true; \
apt-get update; \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
git \
tzdata; \
rm -rf /var/lib/apt/lists/*
ENV PATH="/opt/venv/bin:$PATH"
COPY --from=py_deps /api/.venv /opt/venv
COPY api/ ./api/
ENV OLLAMA_HOST=http://localhost:11434
EXPOSE 8001
CMD ["NODE_ENV=production", "python", "-m", "api.main", "--port", "8001"]
The following lines in the Dockerfile:
echo "deb http://mirrors.aliyun.com/debian/ trixie main contrib non-free non-free-firmware" > /etc/apt/sources.list.d/aliyun.list; \
echo "deb http://mirrors.aliyun.com/debian/ trixie-updates main contrib non-free non-free-firmware" >> /etc/apt/sources.list.d/aliyun.list; \
echo "deb http://mirrors.aliyun.com/debian-security trixie-security main contrib non-free non-free-firmware" >> /etc/apt/sources.list.d/aliyun.list; \
echo "deb http://mirrors.aliyun.com/debian/ trixie-backports main contrib non-free non-free-firmware" >> /etc/apt/sources.list.d/aliyun.list;
are needed only for users in China. In your region, they are probably not necessary. You can change OLLAMA_HOST to the real Ollama address. Make sure to include the protocol prefix (http:// or https://). You can use the official Ollama image.
thanks! I modified the relevant configuration file, which is in this files:
next.config.ts
src/utils/websocketClient.ts
src/app/[owner]/[repo]/page.tsx
src/app/[owner]/[repo]/slides/page.tsx
src/app/[owner]/[repo]/workshop/page.tsx
change the
const SERVER_BASE_URL = process.env.SERVER_BASE_URL || 'http://localhost:8001';
to
const SERVER_BASE_URL = process.env.SERVER_BASE_URL || 'http://<your host ip>:8001';