Originally created by @legaltextai on GitHub (Aug 18, 2024).
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?
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).
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
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @legaltextai on GitHub (Aug 18, 2024).
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"
when added as a pipeline , it works great
thank you