Spaces:
Running
Running
Update app.py
Browse files259 unmodified lines26026126226326426526626726826965 unmodified lines33533633733833934034134234334439 unmodified lines384385386387388389390391259 unmodified linesmax_links: int = 20,) -> str:"""Fetch a web page and return a compact Markdown summary that includes title, keymetadata, readable main text, and outbound links.(Layman's terms: summarize a page with clean text + useful details.)"""if not url or not url.strip():return "Please enter a valid URL."65 unmodified linestitle_chars: int = 80,) -> str:"""Run a DuckDuckGo search and return ultra-compact JSONL lines with short keys tominimize tokens.(Layman's terms: the tiniest useful search output possible.)"""if not query or not query.strip():return ""39 unmodified linesdef Execute_Python(code: str) -> str:"""Execute Python code and return the stdout or error message.Mirrors the standalone code interpreter behavior."""if code is None:return "No code provided."259 unmodified lines26026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931065 unmodified lines37637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941039 unmodified lines450451452453454455456457458459460461462463464465466467468469470471472259 unmodified linesmax_links: int = 20,) -> str:"""Fetch a web page and return a compact Markdown summary containing title, keymetadata, readable main text, and outbound links.This function powers the MCP tool "Fetch_Webpage". Descriptions below areprovided explicitly for MCP clients that surface parameter help.Args:url (str):The absolute URL to fetch. Must return HTML. Example:"https://example.com/article".verbosity (str, optional):Controls how much body text to include. One of:- "Brief" (about 800–1200 chars)- "Standard" (about 3000 chars)- "Full" (no practical cap apart from max_chars)Default: "Standard".include_metadata (bool, optional):If True, include a Metadata section with description, site name,canonical URL, language, and fetched URL. Default: True.include_text (bool, optional):If True, include the readable main text extracted with Readability.Default: True.include_links (bool, optional):If True, include outbound links discovered in the readable sectionof the page. Default: True.max_chars (int, optional):Hard maximum number of characters for the body text, applied afterthe verbosity preset. Use 0 or a negative value to disable the cap(the verbosity preset will still apply). Default: 3000.max_links (int, optional):Maximum number of links to include. Set 0 to omit links even ifinclude_links=True. Default: 20.Returns:str: Markdown that may contain the following sections:- Title (H1)- Metadata (optional)- Text (optional, may be trimmed)- Links (optional, deduped and absolute)Notes:- Only HTML content types are supported. Non-HTML responses return ashort message indicating the unsupported content type.- Link text is shortened to keep tokens small; URLs are absolute andfragments are removed."""if not url or not url.strip():return "Please enter a valid URL."65 unmodified linestitle_chars: int = 80,) -> str:"""Run a DuckDuckGo search and return ultra-compact JSONL with short keys tominimize tokens.This function powers the MCP tool "Search_DuckDuckGo". Each line in theoutput is a JSON object using short keys to reduce token usage.Args:query (str):The search query. Examples: "langchain streaming" or"vector database site:docs.pinecone.io".max_results (int, optional):Maximum number of results to return. Range: 1–20. Default: 5.include_snippets (bool, optional):If True, includes a short snippet for each result (key "s"). Thisincreases tokens. Default: False.max_snippet_chars (int, optional):Character cap applied to each snippet when include_snippets=True.Default: 80.dedupe_domains (bool, optional):If True, only the first result from each domain is kept. Default: True.title_chars (int, optional):Character cap applied to titles. Default: 80.Returns:str: Newline-delimited JSON (JSONL). Each line has:{"t": "title", "u": "url"[, "s": "snippet"]}Error Handling:On search errors, returns a single JSON object with an "error" key."""if not query or not query.strip():return ""39 unmodified linesdef Execute_Python(code: str) -> str:"""Execute arbitrary Python code and return captured stdout or an error message.This function powers the MCP tool "Execute_Python" and mirrors thestandalone code interpreter behavior used in the UI tab.Args:code (str):The Python source code to run. The code executes in a single callwith a fresh global scope. Prints are captured and returned.Returns:str: Combined stdout produced by the code, or the exception text ifexecution failed.Security:The code executes within the current Python process. Do not rununtrusted code in environments where it could access sensitive data."""if code is None:return "No code provided."
app.py+87-6