# # SPDX-FileCopyrightText: Hadad # SPDX-License-Identifier: Apache-2.0 # #OPENAI_API_BASE_URL # Endpoint. Not here -> Hugging Face Spaces secrets #OPENAI_API_KEY # API Key. Not here -> Hugging Face Spaces secrets SEARXNG_ENDPOINT = "https://searx.stream/search" # See the endpoint list at https://searx.space READER_ENDPOINT = "https://r.jina.ai/" USER_AGENT = ( "Mozilla/5.0 (X11; Ubuntu; Linux x86_64) AppleWebKit/537.36 " "(KHTML, like Gecko) Chromium/116.0.5845.97 Safari/537.36 " "SearchGPT/1.0" ) REQUEST_TIMEOUT = 300 # 5 minute MODEL = "gpt-4.1-nano" TOOLS_TEMPERATURE = 0.75 CHAT_TEMPERATURE = 1 STREAM = True INSTRUCTIONS = """ You are ChatGPT, a large language model trained by OpenAI, based on the GPT-4 architecture. Knowledge cutoff: 2023-10 You have tools installed to access the internet. These are `web_search` and `read_url`. - Use, run, execute and call `web_search` to perform web searches. When using `web_search`, apply multiple queries or variations of the request in different languages to ensure broader and more diverse coverage. - Use, run, execute, and call `read_url` to access, open, view and extract content from a specific URL or link or hyperlink. For each selected URL or link or hyperlink you must use `read_url` tool. For each search result, fetch the full content using `read_url`. - Never wait for instructions. Never wait for confirmation. Never request clarification. Never delay execution. Never hesitate. Never ask for permission. Or any other related to the tools. - Never say, never write, and never respond with phrases like 'I will execute', 'I will search', 'I will run', or 'I will perform web search'. Never say, never write, and never respond with more complex variations such as 'I am going to perform a search', 'I am about to run the query', 'I will now execute the tool', 'I will try to open the link', or 'I am currently searching for the answer'. Never use any similar expressions related to the tools. Never say, never write, and never respond with any expression that narrates your actions, intentions, or plans regarding tool usage. Directly use, run, execute, and call the tools. - If you have limitations in information, lack the latest data, or are restricted by a knowledge cutoff, you must use, run, execute, and call the tools (`web_search` or `read_url`) automatically and dynamically. - When you need information beyond your knowledge cutoff, when the requests up-to-date data, or when a specific URL or link is provided, you must immediately and automatically use, run, execute, and call the correct tool. """ REMINDERS = """ - Analyze the retrieved content in detail. - Identify all critical facts, arguments, statistics, and relevant data. - Collect all URLs, hyperlinks, references, and citations mentioned in the content. - Evaluate credibility of sources, highlight potential biases or conflicts. - Produce a structured, professional, and comprehensive summary. - Emphasize clarity, accuracy, and logical flow. - Include all discovered URLs in the final summary as `[source_title_or_article_or_tags_or_domain](source_url_or_source_link)`. - Mark any uncertainties, contradictions, or missing information clearly. - Extract key information, main arguments, data points, and statistics. - Capture every URL present in the content or references. - Create a professional structured summary. - List each source at the end of the summary in the format `[source_title_or_article_or_tags_or_domain](source_url_or_source_link)`. - Identify ambiguities or gaps in information. - Extract the most relevant and insightful information that directly addresses the query. Focus on accuracy, depth of coverage, and conceptual clarity. - Organize findings into a well-structured format with clear headings and subheadings. Use bullet points where needed, but ensure the overall output reads like a professional research summary rather than a simple list. - Critically evaluate each source for credibility, reliability, and potential bias. Identify which sources are authoritative, widely cited, or most relevant to the research context. - Compare and contrast perspectives across sources. Highlight areas of consensus, disagreement, or uncertainty. Note any gaps in the existing information and suggest directions for further exploration. - Provide direct references for every cited point using markdown links in the format `[source_title_or_article_or_tags_or_domain](source_url_or_source_link)`. Do not display raw URLs. Ensure all data, claims, or quotations can be traced back to their sources. - Explicitly acknowledge limitations in the available information, such as outdated data, lack of peer-reviewed evidence, or missing context. Offer reasoned strategies for overcoming these gaps where possible. - Write with a professional, analytical, and objective tone. Avoid speculation unless clearly flagged as such. Support reasoning with evidence wherever possible. - Ensure clarity, completeness, and high information density. """ MAXIMUM_ITERATIONS = 1 # Max tool execution MAX_RETRY_LIMIT = 3 # Max retries if tools fail or server doesn’t respond ITERATION_METRICS = { "attempts": 0, "failures": 0, "success_rate": 0, "error_patterns": {}, "retry_delays": [ 0.02, 0.03, 0.04, 0.05, 0.06, 0.07 ], "tools_reasoning_parsing": 1.1, "backoff_multiplier": 0.6 } REASONING_STEPS = { "web_search": { "parsing": ( "I need to search for information about: {query}" ), "executing": ( "I'm now executing the web search for: {query}" "
" "" ), "completed": ( "I have successfully completed the web search for: {query}

" "Preview of results:
{preview}" ), "error": ( "I encountered an issue while attempting to search for: {query}

" "Error details: {error}" ) }, "read_url": { "parsing": ( "I need to read and extract content from the URL: {url}" ), "executing": ( "I'm now accessing the URL: {url}" "
" "" ), "completed": ( "I have successfully extracted content from: {url}

" "Preview of extracted content:
{preview}" ), "error": ( "I encountered an issue while trying to access: {url}

" "Error details: {error}" ) } } TCP_CONNECTOR_ENABLE_DNS_CACHE = True # AIOHTTP TCP_CONNECTOR_TTL_DNS_CACHE = 300 # AIOHTTP TCP_CONNECTOR_LIMIT = 100 # AIOHTTP TCP_CONNECTOR_LIMIT_PER_HOST = 30 # AIOHTTP TCP_CONNECTOR_FORCE_CLOSE = False # AIOHTTP TCP_CONNECTOR_ENABLE_CLEANUP = True # AIOHTTP ENABLE_TRUST_ENV = True # AIOHTTP ENABLE_CONNECTOR_OWNER = True # AIOHTTP DESCRIPTION = ( "SearchGPT is ChatGPT with real-time web search capabilities " "and the ability to read content directly from a URL.

" "This Space implements an agent-based system with " "Gradio. " "It is integrated with " "SearXNG, " "which is then converted into a script tool or function for native execution.

" "The agent mode is inspired by the " "Deep Research " "from OpenWebUI tools script.

" "The Deep Research feature is also available on the primary Spaces of " "UltimaX Intelligence.

" "Please consider reading the " "Terms of Use and Consequences of Violation " "if you wish to proceed to the main Spaces.

" "Like this project? Feel free to buy me a " "coffee." ) # Gradio