moneychatbot / config.py
hadadrjt's picture
SearchGPT: Allow hybrid mode.
db48229
raw
history blame
8.42 kB
#
# SPDX-FileCopyrightText: Hadad <hadad@linuxmail.org>
# 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 = """
<system>
- 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.
</system>
"""
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}"
"<br>"
"<loading_animation>"
),
"completed": (
"I have successfully completed the web search for: {query}<br><br>"
"Preview of results:<br>{preview}"
),
"error": (
"I encountered an issue while attempting to search for: {query}<br><br>"
"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}"
"<br>"
"<loading_animation>"
),
"completed": (
"I have successfully extracted content from: {url}<br><br>"
"Preview of extracted content:<br>{preview}"
),
"error": (
"I encountered an issue while trying to access: {url}<br><br>"
"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 = (
"<b>SearchGPT</b> is <b>ChatGPT</b> with real-time web search capabilities "
"and the ability to read content directly from a URL.<br><br>"
"This Space implements an agent-based system with "
"<b><a href='https://www.gradio.app' target='_blank'>Gradio</a></b>. "
"It is integrated with "
"<b><a href='https://docs.searxng.org' target='_blank'>SearXNG</a></b>, "
"which is then converted into a script tool or function for native execution.<br><br>"
"The agent mode is inspired by the "
"<b><a href='https://openwebui.com/t/hadad/deep_research' target='_blank'>Deep Research</a></b> "
"from <b><a href='https://docs.openwebui.com' target='_blank'>OpenWebUI</a></b> tools script.<br><br>"
"The <b>Deep Research</b> feature is also available on the primary Spaces of "
"<b><a href='https://umint-openwebui.hf.space' target='_blank'>UltimaX Intelligence</a></b>.<br><br>"
"Please consider reading the "
"<b><a href='https://huggingface.co/spaces/umint/ai/discussions/37#68b55209c51ca52ed299db4c' "
"target='_blank'>Terms of Use and Consequences of Violation</a></b> "
"if you wish to proceed to the main Spaces.<br><br>"
"<b>Like this project? Feel free to buy me a "
"<a href='https://ko-fi.com/hadad' target='_blank'>coffee</a></b>."
) # Gradio