[GH-ISSUE #4705] the model is not using the tool, anything I should do differently? #13706

Closed
opened 2026-04-19 20:20:48 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @legaltextai on GitHub (Aug 18, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/4705

basically, the tool is an api call to search for relevant cases , it's enabled and added to the model settings. also the prompt says to use the tool and when but it never does. anything i should do different?

import requests
import urllib3

Disable SSL warnings

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

class Tools:
def init(self):
self.search_api_url = "url_to_api/endpoint"

def search_custom_api(self, query: str) -> str:
    """
    Search using the custom Search and Rerank API and return the results.
    :param query: The query to search for.
    :return: A formatted string containing the search results.
    """
    data = {"query": query}

    try:
        response = requests.post(self.search_api_url, json=data, verify=False)
        response.raise_for_status()
        search_results = response.json()

        jurisdiction = search_results.get("jurisdiction", "Unknown")
        results = search_results.get("results", [])

        formatted_response = f"Jurisdiction: {jurisdiction}\n\n"
        for i, result in enumerate(results[:3], 1):  # Limit to top 3 results
            formatted_response += f"Result {i}:\n{result.get('text', '')}...\n\n"

        return formatted_response
    except requests.RequestException as e:
        return f"Error occurred while querying the search API: {str(e)}"

when added as a pipeline , it works great

thank you

Originally created by @legaltextai on GitHub (Aug 18, 2024). Original GitHub issue: https://github.com/open-webui/open-webui/issues/4705 basically, the tool is an api call to search for relevant cases , it's enabled and added to the model settings. also the prompt says to use the tool and when but it never does. anything i should do different? import requests import urllib3 # Disable SSL warnings urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) class Tools: def __init__(self): self.search_api_url = "url_to_api/endpoint" def search_custom_api(self, query: str) -> str: """ Search using the custom Search and Rerank API and return the results. :param query: The query to search for. :return: A formatted string containing the search results. """ data = {"query": query} try: response = requests.post(self.search_api_url, json=data, verify=False) response.raise_for_status() search_results = response.json() jurisdiction = search_results.get("jurisdiction", "Unknown") results = search_results.get("results", []) formatted_response = f"Jurisdiction: {jurisdiction}\n\n" for i, result in enumerate(results[:3], 1): # Limit to top 3 results formatted_response += f"Result {i}:\n{result.get('text', '')}...\n\n" return formatted_response except requests.RequestException as e: return f"Error occurred while querying the search API: {str(e)}" when added as a pipeline , it works great thank you
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#13706