Link LLM to Wiki #101

Closed
opened 2026-10-05 01:22:22 +02:00 by adam · 9 comments
Owner

A enhancement request to link the LLM model to use wiki module when enabled.

I would like it to

  1. LLM Determine the subject of the question from input, search Wikipedia, and optionally Google using built-in or existing includes or functions.

  2. Run a new query with the item 1 results included providing a final output to the user

  3. Try and keep with the framework of a basic model or an advanced model to allow more flexibility

A enhancement request to link the LLM model to use wiki module when enabled. I would like it to 1. LLM Determine the subject of the question from input, search Wikipedia, and optionally Google using built-in or existing includes or functions. 2. Run a new query with the item 1 results included providing a final output to the user 3. Try and keep with the framework of a basic model or an advanced model to allow more flexibility <!-- github-sync-id:3554565993 -->
adam closed this issue 2026-10-05 01:22:22 +02:00
Author
Owner
Ollama's api https://docs.ollama.com/api <!-- github-comment-id:3449020036 -->
Author
Owner

Ollama embedding

https://ollama.com/blog/embedding-models

I don't mind using Python module ollama or chromadb if there is some good trade offs of performance or value of space. I would prefer to use the web api only. A better way might be to ..

I would also like if OpenWebUI was an option to be called vs ollama api if not messy to add. This would actually likely be a much better way to let anyone build a model with a rag

https://openwebui.com/getting-started/api-endpoints/

https://github.com/open-webui/open-webui

Ollama embedding https://ollama.com/blog/embedding-models I don't mind using Python module ollama or chromadb if there is some good trade offs of performance or value of space. I would prefer to use the web api only. A better way might be to .. I would also like if OpenWebUI was an option to be called vs ollama api if not messy to add. This would actually likely be a much better way to let anyone build a model with a rag https://openwebui.com/getting-started/api-endpoints/ https://github.com/open-webui/open-webui <!-- github-comment-id:3449023893 -->
Author
Owner

Example to call OpenWebUI

import requests

def chat_with_model(token):
    url = 'http://localhost:3000/api/chat/completions'
    headers = {
        'Authorization': f'Bearer {token}',
        'Content-Type': 'application/json'
    }
    data = {
      "model": "granite3.1-dense:8b",
      "messages": [
        {
          "role": "user",
          "content": "Why is the sky blue?"
        }
      ]
    }
    response = requests.post(url, headers=headers, json=data)
    return response.json()
Example to call OpenWebUI ``` import requests def chat_with_model(token): url = 'http://localhost:3000/api/chat/completions' headers = { 'Authorization': f'Bearer {token}', 'Content-Type': 'application/json' } data = { "model": "granite3.1-dense:8b", "messages": [ { "role": "user", "content": "Why is the sky blue?" } ] } response = requests.post(url, headers=headers, json=data) return response.json() ``` <!-- github-comment-id:3449025588 -->
Author
Owner

Ollama API Proxy Support in OpenWebUI api

If you want to interact directly with Ollama models—including for embedding generation or raw prompt streaming—Open WebUI offers a transparent passthrough to the native Ollama API via a proxy route.

Base URL: /ollama/
Reference: Ollama API Documentation
🔁 Generate Completion (Streaming)

curl http://localhost:3000/ollama/api/generate -d '{ "model": "llama3.2", "prompt": "Why is the sky blue?" }'

📦 List Available Models

curl http://localhost:3000/ollama/api/tags

🧠 Generate Embeddings

curl -X POST http://localhost:3000/ollama/api/embed -d '{ "model": "llama3.2", "input": ["Open WebUI is great!", "Let's generate embeddings."] }'

This is ideal for building search indexes, retrieval systems, or custom pipelines using Ollama models behind the Open WebUI.

Ollama API Proxy Support in OpenWebUI api If you want to interact directly with Ollama models—including for embedding generation or raw prompt streaming—Open WebUI offers a transparent passthrough to the native Ollama API via a proxy route. Base URL: /ollama/<api> Reference: Ollama API Documentation 🔁 Generate Completion (Streaming) ` curl http://localhost:3000/ollama/api/generate -d '{ "model": "llama3.2", "prompt": "Why is the sky blue?" }' ` 📦 List Available Models ` curl http://localhost:3000/ollama/api/tags ` 🧠 Generate Embeddings ` curl -X POST http://localhost:3000/ollama/api/embed -d '{ "model": "llama3.2", "input": ["Open WebUI is great!", "Let's generate embeddings."] }' ` This is ideal for building search indexes, retrieval systems, or custom pipelines using Ollama models behind the Open WebUI. <!-- github-comment-id:3449026282 -->
Author
Owner

Retrieval Augmented Generation (RAG) in OpenWebUI

The Retrieval Augmented Generation (RAG) feature allows you to enhance responses by incorporating data from external sources. Below, you will find the methods for managing files and knowledge collections via the API, and how to use them in chat completions effectively.

Uploading Files

To utilize external data in RAG responses, you first need to upload the files. The content of the uploaded file is automatically extracted and stored in a vector database.

Endpoint: POST /api/v1/files/

Curl Example:

curl -X POST -H "Authorization: Bearer YOUR_API_KEY" -H "Accept: application/json" \
-F "file=@/path/to/your/file" http://localhost:3000/api/v1/files/

Python Example:

import requests

def upload_file(token, file_path):
    url = 'http://localhost:3000/api/v1/files/'
    headers = {
        'Authorization': f'Bearer {token}',
        'Accept': 'application/json'
    }
    files = {'file': open(file_path, 'rb')}
    response = requests.post(url, headers=headers, files=files)
    return response.json()

Adding Files to Knowledge Collections

After uploading, you can group files into a knowledge collection or reference them individually in chats.

Endpoint: POST /api/v1/knowledge/{id}/file/add

Curl Example:

curl -X POST http://localhost:3000/api/v1/knowledge/{knowledge_id}/file/add \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"file_id": "your-file-id-here"}'

Python Example:

import requests

def add_file_to_knowledge(token, knowledge_id, file_id):
    url = f'http://localhost:3000/api/v1/knowledge/{knowledge_id}/file/add'
    headers = {
        'Authorization': f'Bearer {token}',
        'Content-Type': 'application/json'
    }
    data = {'file_id': file_id}
    response = requests.post(url, headers=headers, json=data)
    return response.json()

Using Files and Collections in Chat Completions

You can reference both individual files or entire collections in your RAG queries for enriched responses.

Using an Individual File in Chat Completions

This method is beneficial when you want to focus the chat model's response on the content of a specific file.

Endpoint: POST /api/chat/completions

Curl Example:

curl -X POST http://localhost:3000/api/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
      "model": "gpt-4-turbo",
      "messages": [
        {"role": "user", "content": "Explain the concepts in this document."}
      ],
      "files": [
        {"type": "file", "id": "your-file-id-here"}
      ]
    }'

Python Example:

import requests

def chat_with_file(token, model, query, file_id):
    url = 'http://localhost:3000/api/chat/completions'
    headers = {
        'Authorization': f'Bearer {token}',
        'Content-Type': 'application/json'
    }
    payload = {
        'model': model,
        'messages': [{'role': 'user', 'content': query}],
        'files': [{'type': 'file', 'id': file_id}]
    }
    response = requests.post(url, headers=headers, json=payload)
    return response.json()

Using a Knowledge Collection in Chat Completions

Leverage a knowledge collection to enhance the response when the inquiry may benefit from a broader context or multiple documents.

Endpoint: POST /api/chat/completions

Curl Example:

curl -X POST http://localhost:3000/api/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
      "model": "gpt-4-turbo",
      "messages": [
        {"role": "user", "content": "Provide insights on the historical perspectives covered in the collection."}
      ],
      "files": [
        {"type": "collection", "id": "your-collection-id-here"}
      ]
    }'

Python Example:

import requests

def chat_with_collection(token, model, query, collection_id):
    url = 'http://localhost:3000/api/chat/completions'
    headers = {
        'Authorization': f'Bearer {token}',
        'Content-Type': 'application/json'
    }
    payload = {
        'model': model,
        'messages': [{'role': 'user', 'content': query}],
        'files': [{'type': 'collection', 'id': collection_id}]
    }
    response = requests.post(url, headers=headers, json=payload)
    return response.json()

These methods enable effective utilization of external knowledge via uploaded files and curated knowledge collections, enhancing chat applications' capabilities using the Open WebUI API. Whether using files individually or within collections, you can customize the integration based on your specific needs.

Retrieval Augmented Generation (RAG) in OpenWebUI The Retrieval Augmented Generation (RAG) feature allows you to enhance responses by incorporating data from external sources. Below, you will find the methods for managing files and knowledge collections via the API, and how to use them in chat completions effectively. Uploading Files To utilize external data in RAG responses, you first need to upload the files. The content of the uploaded file is automatically extracted and stored in a vector database. Endpoint: POST /api/v1/files/ Curl Example: ``` curl -X POST -H "Authorization: Bearer YOUR_API_KEY" -H "Accept: application/json" \ -F "file=@/path/to/your/file" http://localhost:3000/api/v1/files/ ``` Python Example: ``` import requests def upload_file(token, file_path): url = 'http://localhost:3000/api/v1/files/' headers = { 'Authorization': f'Bearer {token}', 'Accept': 'application/json' } files = {'file': open(file_path, 'rb')} response = requests.post(url, headers=headers, files=files) return response.json() ``` Adding Files to Knowledge Collections After uploading, you can group files into a knowledge collection or reference them individually in chats. Endpoint: POST /api/v1/knowledge/{id}/file/add Curl Example: ``` curl -X POST http://localhost:3000/api/v1/knowledge/{knowledge_id}/file/add \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"file_id": "your-file-id-here"}' ``` Python Example: ``` import requests def add_file_to_knowledge(token, knowledge_id, file_id): url = f'http://localhost:3000/api/v1/knowledge/{knowledge_id}/file/add' headers = { 'Authorization': f'Bearer {token}', 'Content-Type': 'application/json' } data = {'file_id': file_id} response = requests.post(url, headers=headers, json=data) return response.json() ``` Using Files and Collections in Chat Completions You can reference both individual files or entire collections in your RAG queries for enriched responses. Using an Individual File in Chat Completions This method is beneficial when you want to focus the chat model's response on the content of a specific file. Endpoint: POST /api/chat/completions Curl Example: ``` curl -X POST http://localhost:3000/api/chat/completions \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4-turbo", "messages": [ {"role": "user", "content": "Explain the concepts in this document."} ], "files": [ {"type": "file", "id": "your-file-id-here"} ] }' ``` Python Example: ``` import requests def chat_with_file(token, model, query, file_id): url = 'http://localhost:3000/api/chat/completions' headers = { 'Authorization': f'Bearer {token}', 'Content-Type': 'application/json' } payload = { 'model': model, 'messages': [{'role': 'user', 'content': query}], 'files': [{'type': 'file', 'id': file_id}] } response = requests.post(url, headers=headers, json=payload) return response.json() ``` Using a Knowledge Collection in Chat Completions Leverage a knowledge collection to enhance the response when the inquiry may benefit from a broader context or multiple documents. Endpoint: POST /api/chat/completions Curl Example: ``` curl -X POST http://localhost:3000/api/chat/completions \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4-turbo", "messages": [ {"role": "user", "content": "Provide insights on the historical perspectives covered in the collection."} ], "files": [ {"type": "collection", "id": "your-collection-id-here"} ] }' ``` Python Example: ``` import requests def chat_with_collection(token, model, query, collection_id): url = 'http://localhost:3000/api/chat/completions' headers = { 'Authorization': f'Bearer {token}', 'Content-Type': 'application/json' } payload = { 'model': model, 'messages': [{'role': 'user', 'content': query}], 'files': [{'type': 'collection', 'id': collection_id}] } response = requests.post(url, headers=headers, json=payload) return response.json() ``` These methods enable effective utilization of external knowledge via uploaded files and curated knowledge collections, enhancing chat applications' capabilities using the Open WebUI API. Whether using files individually or within collections, you can customize the integration based on your specific needs. <!-- github-comment-id:3449029344 -->
Author
Owner

It would be cool to keep legacy(with local prompt check against Wikipedia,or Google) but give option for OpenWebUI?!🧩

Advantages of Using Open WebUI as a Unified LLM Provider

Open WebUI offers a myriad of benefits, making it an essential tool for developers and businesses alike:

Unified Interface: Simplify your interactions with different LLMs through a single, integrated platform.
Ease of Implementation: Quick start integration with comprehensive documentation and community support.

It would be cool to keep legacy(with local prompt check against Wikipedia,or Google) but give option for OpenWebUI?!🧩 Advantages of Using Open WebUI as a Unified LLM Provider Open WebUI offers a myriad of benefits, making it an essential tool for developers and businesses alike: Unified Interface: Simplify your interactions with different LLMs through a single, integrated platform. Ease of Implementation: Quick start integration with comprehensive documentation and community support. <!-- github-comment-id:3449031998 -->
Author
Owner

This is the primary file which needs refactored for this request.

https://github.com/SpudGunMan/meshing-around/blob/main/modules/llm.py

It could be totally rewritten we just need to maintain

def llm_query(input, nodeID=0, location_name=None)

It will keep compatibility externally

This is the primary file which needs refactored for this request. https://github.com/SpudGunMan/meshing-around/blob/main/modules/llm.py It could be totally rewritten we just need to maintain `def llm_query(input, nodeID=0, location_name=None)` It will keep compatibility externally <!-- github-comment-id:3449040386 -->
Author
Owner

Here is a repository/library which might be cool?

https://github.com/mozanunal/llm-tools-kiwix

If we can do it all in house but making sure we can have similar functionality

https://github.com/SpudGunMan/meshing-around/blob/main/modules/wiki.py

This is the current methods we use to look up Wikipedia, which will fall back to kiwix if enabled

Here is a repository/library which might be cool? https://github.com/mozanunal/llm-tools-kiwix If we can do it all in house but making sure we can have similar functionality https://github.com/SpudGunMan/meshing-around/blob/main/modules/wiki.py This is the current methods we use to look up Wikipedia, which will fall back to kiwix if enabled <!-- github-comment-id:3449132598 -->
Author
Owner

Ollama API Proxy Support in OpenWebUI api

If you want to interact directly with Ollama models—including for embedding generation or raw prompt streaming—Open WebUI offers a transparent passthrough to the native Ollama API via a proxy route.

Base URL: /ollama/
Reference: Ollama API Documentation
🔁 Generate Completion (Streaming)

curl http://localhost:3000/ollama/api/generate -d '{ "model": "llama3.2", "prompt": "Why is the sky blue?" }'

📦 List Available Models

curl http://localhost:3000/ollama/api/tags

🧠 Generate Embeddings

curl -X POST http://localhost:3000/ollama/api/embed -d '{ "model": "llama3.2", "input": ["Open WebUI is great!", "Let's generate embeddings."] }'

This is ideal for building search indexes, retrieval systems, or custom pipelines using Ollama models behind the Open WebUI.

This would allow the existing along with new easily but it would need a switch to OpenWebUI which means a larger overhead overall. Why keeping the current lighter method as a fall back would be nice

> Ollama API Proxy Support in OpenWebUI api > > If you want to interact directly with Ollama models—including for embedding generation or raw prompt streaming—Open WebUI offers a transparent passthrough to the native Ollama API via a proxy route. > > Base URL: /ollama/<api> > Reference: Ollama API Documentation > 🔁 Generate Completion (Streaming) > > ` > curl http://localhost:3000/ollama/api/generate -d '{ > "model": "llama3.2", > "prompt": "Why is the sky blue?" > }' > ` > > 📦 List Available Models > > > ` > curl http://localhost:3000/ollama/api/tags > ` > > > 🧠 Generate Embeddings > > > ` > curl -X POST http://localhost:3000/ollama/api/embed -d '{ > "model": "llama3.2", > "input": ["Open WebUI is great!", "Let's generate embeddings."] > }' > ` > > This is ideal for building search indexes, retrieval systems, or custom pipelines using Ollama models behind the Open WebUI. This would allow the existing along with new easily but it would need a switch to OpenWebUI which means a larger overhead overall. Why keeping the current lighter method as a fall back would be nice <!-- github-comment-id:3449355012 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/meshing-around#101