[GH-ISSUE #12648] issue: How to debug tools #55333

Closed
opened 2026-05-05 17:27:22 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @gongshaojie12 on GitHub (Apr 9, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/12648

Check Existing Issues

  • I have searched the existing issues and discussions.
  • I am using the latest version of Open WebUI.

Installation Method

Pip Install

Open WebUI Version

v0.6.2

Ollama Version (if applicable)

No response

Operating System

centos8

Browser (if applicable)

No response

Confirmation

  • I have read and followed all instructions in README.md.
  • I am using the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have listed steps to reproduce the bug in detail.

Expected Behavior

I have now customized a tool for recalling the RagFlow knowledge base, and the code is as follows:

# -*- coding: utf-8 -*-
from pydantic import BaseModel, Field
import requests


class Tools:
    class Valves(BaseModel):
        URL: str = Field(
            default="localhost",
            description="The ragflow url",
        )
        API_KEY: str = Field(
            default="apikey",
            description="The api key",
        )
        DATASET_IDS: list = Field(
            default=["id"],
            description="The IDs of the datasets to search",
        )
        PAGE: int = Field(
            default=1,
            description="Specifies the page on which the chunks will be displayed",
        )
        PAGE_SIZE: int = Field(
            default=30, description="The maximum number of chunks on each page"
        )
        SIMILARITY_THRESHOLD: float = Field(
            default=0.2, description="The minimum similarity score"
        )
        VECTOR_SIMILARITY_WEIGHT: float = Field(
            default=0.3, description="The weight of vector cosine similarity"
        )

    def __init__(self):
        self.valves = self.Valves()

    def retrieval(self, query: str) -> str:
        print("query:{}".format(query))
        headers = {
            "Content-Type": "application/json",
            "Authorization": "Bearer {}".format(self.valves.API_KEY),
        }
        payload = {
            "question": query,
            "dataset_ids": self.valves.DATASET_IDS,
            "page": self.valves.PAGE,
            "page_size": self.valves.PAGE_SIZE,
            "similarity_threshold": self.valves.SIMILARITY_THRESHOLD,
            "vector_similarity_weight": self.valves.VECTOR_SIMILARITY_WEIGHT,
        }
        contents = []
        try:
            response = requests.post(self.valves.URL, headers=headers, json=payload)
            if response.status_code == 200:
                result = response.json()
                if "data" in result:
                    data = result["data"]
                    if "chunks" in data:
                        chunks = data["chunks"]
                        for chunk in chunks:
                            contents.append(chunk["content"])
                    else:
                        return "Data parse error"
                else:
                    return "Data parse error"

                return "。".join(contents)
            else:
                return response.status_code
        except Exception as e:
            return "Error:{}".format(str(e))

After importing it into the tools of Open-WebUI and enabling it in the chat dialog box, the tool didn't work. How should I debug this tool?

Note: The unit test for this tool has already passed.

Actual Behavior

The tool did not work and could not be debugged. I hope debugging can be performed.

Steps to Reproduce

None

Logs & Screenshots

None

Additional Information

No response

Originally created by @gongshaojie12 on GitHub (Apr 9, 2025). Original GitHub issue: https://github.com/open-webui/open-webui/issues/12648 ### Check Existing Issues - [x] I have searched the existing issues and discussions. - [x] I am using the latest version of Open WebUI. ### Installation Method Pip Install ### Open WebUI Version v0.6.2 ### Ollama Version (if applicable) _No response_ ### Operating System centos8 ### Browser (if applicable) _No response_ ### Confirmation - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of **both** Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have listed steps to reproduce the bug in detail. ### Expected Behavior I have now customized a tool for recalling the RagFlow knowledge base, and the code is as follows: ``` # -*- coding: utf-8 -*- from pydantic import BaseModel, Field import requests class Tools: class Valves(BaseModel): URL: str = Field( default="localhost", description="The ragflow url", ) API_KEY: str = Field( default="apikey", description="The api key", ) DATASET_IDS: list = Field( default=["id"], description="The IDs of the datasets to search", ) PAGE: int = Field( default=1, description="Specifies the page on which the chunks will be displayed", ) PAGE_SIZE: int = Field( default=30, description="The maximum number of chunks on each page" ) SIMILARITY_THRESHOLD: float = Field( default=0.2, description="The minimum similarity score" ) VECTOR_SIMILARITY_WEIGHT: float = Field( default=0.3, description="The weight of vector cosine similarity" ) def __init__(self): self.valves = self.Valves() def retrieval(self, query: str) -> str: print("query:{}".format(query)) headers = { "Content-Type": "application/json", "Authorization": "Bearer {}".format(self.valves.API_KEY), } payload = { "question": query, "dataset_ids": self.valves.DATASET_IDS, "page": self.valves.PAGE, "page_size": self.valves.PAGE_SIZE, "similarity_threshold": self.valves.SIMILARITY_THRESHOLD, "vector_similarity_weight": self.valves.VECTOR_SIMILARITY_WEIGHT, } contents = [] try: response = requests.post(self.valves.URL, headers=headers, json=payload) if response.status_code == 200: result = response.json() if "data" in result: data = result["data"] if "chunks" in data: chunks = data["chunks"] for chunk in chunks: contents.append(chunk["content"]) else: return "Data parse error" else: return "Data parse error" return "。".join(contents) else: return response.status_code except Exception as e: return "Error:{}".format(str(e)) ``` After importing it into the tools of Open-WebUI and enabling it in the chat dialog box, the tool didn't work. How should I debug this tool? **Note**: The unit test for this tool has already passed. ### Actual Behavior The tool did not work and could not be debugged. I hope debugging can be performed. ### Steps to Reproduce None ### Logs & Screenshots None ### Additional Information _No response_
GiteaMirror added the bug label 2026-05-05 17:27:22 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#55333