### Install Scrapling Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/examples/README.md Installs the Scrapling library with all optional dependencies and forces an update. This is a prerequisite for running the examples. ```bash pip install "scrapling[all]>=0.4.2" scrapling install --force ``` -------------------------------- ### Install Chrome for Playwright Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/references/fetching/dynamic.md Command line instruction to install the Google Chrome browser binary for use with Playwright. ```bash playwright install chrome ``` -------------------------------- ### Start EchoBot Service (Python) Source: https://github.com/kdaip/echobot/blob/main/README.md Launches the EchoBot application, including the chat platform Gateway and the web UI. This command starts the main server process. ```python python -m echobot app ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/kdaip/echobot/blob/main/README_EN.md Sets up the environment variables for connecting to an LLM provider. Copy the example file and fill in your API key, model, and base URL. ```text LLM_API_KEY=your_api_key_here LLM_MODEL=deepseek-chat LLM_BASE_URL=https://api.deepseek.com/v1 ``` -------------------------------- ### Start EchoBot Gateway Source: https://context7.com/kdaip/echobot/llms.txt Command to launch the multi-platform gateway for EchoBot. This is the primary command to start the EchoBot service. ```bash python -m echobot gateway ``` -------------------------------- ### Execute Basic HTTP GET Request Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/references/fetching/static.md Shows how to perform a simple GET request using the Fetcher class and extract data using CSS selectors. ```python from scrapling.fetchers import Fetcher page = Fetcher.get('https://example.com') if page.status == 200: title = page.css('title::text').get() links = page.css('a::attr(href)').getall() ``` -------------------------------- ### Install Project Dependencies (Python) Source: https://github.com/kdaip/echobot/blob/main/README.md Installs all necessary Python packages for the EchoBot project. Requires Python 3.11 or higher. ```shell pip install -r requirements.txt ``` -------------------------------- ### Basic Scrapling GET Request Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/SKILL.md Demonstrates a basic GET request to download content from a URL and save it to a file. This is the simplest form of using the scrapling extract get command. ```bash scrapling extract get "https://news.site.com" news.md ``` -------------------------------- ### Run Scrapling Examples Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/examples/README.md Executes the Scrapling Python scripts for various scraping scenarios. Each script demonstrates a different Scrapling tool. ```bash python examples/01_fetcher_session.py python examples/02_dynamic_session.py # Opens a visible browser python examples/03_stealthy_session.py # Opens a visible stealth browser python examples/04_spider.py # Auto-crawls all pages, exports quotes.json ``` -------------------------------- ### Command-Line Interface (CLI) Tools Source: https://context7.com/kdaip/echobot/llms.txt Provides instructions for using EchoBot's command-line interface to start the application or chat interactively. ```APIDOC ## Command-Line Interface (CLI) Tools ### Description EchoBot provides CLI commands to manage and run the application. ### Starting the Service To start the full application, including the Web UI and platform gateway: ```bash python -m echobot app ``` To start only the interactive chat mode: ```bash python -m echobot chat ``` ``` -------------------------------- ### EchoBot .env Configuration Example Source: https://context7.com/kdaip/echobot/llms.txt Example configuration file (.env) for EchoBot, covering LLM, Agent, TTS, and ASR settings. This file allows customization of various EchoBot functionalities. ```dotenv # LLM Configuration (OpenAI compatible format) LLM_API_KEY=your-api-key LLM_MODEL=deepseek-chat LLM_BASE_URL=https://api.deepseek.com/v1 ECHOBOT_LLM_SUPPORTS_IMAGE_INPUT=true # Agent Configuration ECHOBOT_AGENT_MAX_STEPS=50 ECHOBOT_DELEGATED_ACK_ENABLED=true # TTS Configuration ECHOBOT_TTS_PROVIDER=edge # ASR Configuration ECHOBOT_ASR_PROVIDER=sherpa-sense-voice ECHOBOT_ASR_SAMPLE_RATE=16000 # Custom TTS (OpenAI compatible) ECHOBOT_TTS_OPENAI_MODEL=Qwen/Qwen3-TTS ECHOBOT_TTS_OPENAI_BASE_URL=http://localhost:8091/v1 ``` -------------------------------- ### Run EchoBot Service - Bash Source: https://context7.com/kdaip/echobot/llms.txt Command-line instructions for starting the EchoBot application. Use 'python -m echobot app' to launch the full application including the Web UI and platform gateway, or 'python -m echobot chat' for an interactive chat-only mode. ```bash # 启动完整应用(Web UI + 平台网关) python -m echobot app # 仅启动交互式聊天 python -m echobot chat ``` -------------------------------- ### Advanced PDF Cropping using pypdf Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/pdf/reference.md Demonstrates the initial setup for advanced PDF cropping using the pypdf library. This snippet shows how to open a PDF for reading and prepare a writer object for creating a new PDF, which would then involve applying cropping transformations. ```python from pypdf import PdfWriter, PdfReader reader = PdfReader("input.pdf") writer = PdfWriter() # Further operations to define crop boxes would follow here ``` -------------------------------- ### Configure Environment Variables (Shell) Source: https://github.com/kdaip/echobot/blob/main/README.md Sets up the .env file for EchoBot by copying the example and filling in LLM API credentials. This is crucial for connecting to language model services. ```shell cp .env.example .env # Then, edit .env to add your LLM_API_KEY, LLM_MODEL, and LLM_BASE_URL. ``` -------------------------------- ### EchoBot TTSService - Python Source: https://context7.com/kdaip/echobot/llms.txt Demonstrates the Text-to-Speech (TTS) service in EchoBot, allowing for voice synthesis using different providers. This example shows how to initialize the service, synthesize speech with specific voice parameters, save the audio output, and list available voices. ```python from echobot.tts import TTSService from echobot.tts.providers.edge import EdgeTTSProvider # 创建 TTS 服务 tts_service = TTSService( providers={ "edge": EdgeTTSProvider(), }, default_provider="edge" ) # 合成语音 speech = await tts_service.synthesize( text="你好,我是你的AI助手!", voice="zh-CN-XiaoxiaoNeural", rate="+10%", pitch="+5%" ) # 保存音频 with open("output.mp3", "wb") as f: f.write(speech.audio_bytes) # 获取可用语音 voices = await tts_service.list_voices("edge") for voice in voices: print(f"{voice.short_name}: {voice.display_name}") ``` -------------------------------- ### Perform HTTP PUT Requests with Scrapling Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/references/fetching/static.md Demonstrates how to send PUT requests with form-encoded data, proxy settings, and impersonation headers. Examples are provided for both synchronous and asynchronous execution. ```python from scrapling.fetchers import Fetcher page = Fetcher.put('https://example.com/update', data={'status': 'updated'}, stealthy_headers=True, impersonate="chrome") from scrapling.fetchers import AsyncFetcher page = await AsyncFetcher.put('https://example.com/update', data={'status': 'updated'}, impersonate="chrome") ``` -------------------------------- ### Save, Retrieve, and Relocate Elements (Python) Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/references/parsing/adaptive.md Demonstrates the manual process of finding an element by text, saving its unique properties with a custom identifier, and then retrieving and relocating it within the adaptive feature. It shows how to get the element as a dictionary or an lxml.etree object. ```python >>> element = page.find_by_text('Tipping the Velvet', first_match=True) >>> page.save(element, 'my_special_element') >>> element_dict = page.retrieve('my_special_element') >>> page.relocate(element_dict, selector_type=True) [] >>> page.relocate(element_dict, selector_type=True).css('::text').getall() ['Tipping the Velvet'] >>> page.relocate(element_dict) [] ``` -------------------------------- ### Upload Background Image - Bash Source: https://context7.com/kdaip/echobot/llms.txt This example shows how to upload a custom background image using `curl`. It sends a POST request to the '/web/stage/backgrounds' endpoint with the image file. Replace 'background.jpg' with your actual image file name. ```bash curl -X POST http://127.0.0.1:8000/web/stage/backgrounds \ -F "image=@background.jpg" ``` -------------------------------- ### Accessing Crawl Results and Statistics with Echobot Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/references/spiders/advanced.md Illustrates how to retrieve and interpret the results of a crawl using Echobot's `start()` method. It shows how to access the list of scraped items, check crawl completion status, and analyze detailed statistics such as request counts, response bytes, and duration. ```python result = MySpider().start() # Items print(f"Total items: {len(result.items)}") result.items.to_json("output.json", indent=True) # Did the crawl complete? print(f"Completed: {result.completed}") print(f"Paused: {result.paused}") # Statistics stats = result.stats print(f"Requests: {stats.requests_count}") print(f"Failed: {stats.failed_requests_count}") print(f"Blocked: {stats.blocked_requests_count}") print(f"Offsite filtered: {stats.offsite_requests_count}") print(f"Items scraped: {stats.items_scraped}") print(f"Items dropped: {stats.items_dropped}") print(f"Response bytes: {stats.response_bytes}") print(f"Duration: {stats.elapsed_seconds:.1f}s") print(f"Speed: {stats.requests_per_second:.1f} req/s") ``` -------------------------------- ### Encrypt and Decrypt PDFs with qpdf Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/pdf/reference.md Provides examples of using `qpdf` for advanced PDF encryption and decryption. This covers adding password protection with specific user permissions (like preventing printing or modification) and removing existing encryption. ```bash # Add password protection with specific permissions qpdf --encrypt user_pass owner_pass 256 --print=none --modify=none -- input.pdf encrypted.pdf # Check encryption status qpdf --show-encryption encrypted.pdf # Remove password protection (requires password) qpdf --password=secret123 --decrypt encrypted.pdf decrypted.pdf ``` -------------------------------- ### Initialize Parser and Load HTML Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/references/migrating_from_beautifulsoup.md Demonstrates how to import the respective libraries and initialize the parser with an HTML string. ```python # BeautifulSoup from bs4 import BeautifulSoup soup = BeautifulSoup(html, 'html.parser') # Scrapling from scrapling.parser import Selector page = Selector(html) ``` -------------------------------- ### Download Files from URL Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/references/fetching/static.md Demonstrates how to fetch binary content from a URL and save it to the local filesystem. ```python from scrapling.fetchers import Fetcher page = Fetcher.get('https://example.com/image.png') with open(file='image.png', mode='wb') as f: f.write(page.body) ``` -------------------------------- ### Importing the Fetcher class Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/references/fetching/static.md Demonstrates the standard import pattern required to initialize the Fetcher class for making HTTP requests. ```python from scrapling.fetchers import Fetcher ``` -------------------------------- ### GET /get Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/references/mcp-server.md Performs an HTTP GET request to a single URL with advanced features like browser fingerprint impersonation and content extraction. ```APIDOC ## GET /get ### Description Performs a fast HTTP GET request with browser fingerprint impersonation (TLS, headers). Suitable for static pages with no/low bot protection. ### Method GET ### Endpoint /get ### Parameters #### Query Parameters - **url** (str) - Required - URL to fetch - **extraction_type** (str) - Optional - Output format. Allowed values: "markdown", "html", "text". Default: "markdown" - **css_selector** (str) - Optional - CSS selector to narrow content (applied after `main_content_only`). - **main_content_only** (bool) - Optional - Restrict to `` content. Default: true - **impersonate** (str) - Optional - Browser fingerprint to impersonate. Default: "chrome" - **proxy** (str) - Optional - Proxy URL, e.g. "http://user:pass@host:port" - **proxy_auth** (dict) - Optional - Proxy authentication details in the format `{"username": "...", "password": "..."}`. - **auth** (dict) - Optional - HTTP basic authentication details, same format as `proxy_auth`. - **timeout** (number) - Optional - Seconds before timeout. Default: 30 - **retries** (int) - Optional - Retry attempts on failure. Default: 3 - **retry_delay** (int) - Optional - Seconds between retries. Default: 1 - **stealthy_headers** (bool) - Optional - Generate realistic browser headers and Google referer. Default: true - **http3** (bool) - Optional - Use HTTP/3 (may conflict with `impersonate`). Default: false - **follow_redirects** (bool) - Optional - Follow HTTP redirects. Default: true - **max_redirects** (int) - Optional - Max redirects (-1 for unlimited). Default: 30 - **headers** (dict) - Optional - Custom request headers. - **cookies** (dict) - Optional - Request cookies. - **params** (dict) - Optional - Query string parameters. - **verify** (bool) - Optional - Verify HTTPS certificates. Default: true ### Response #### Success Response (200) - **status** (int) - The status code of the response. - **content** (list of str) - The extracted content from the URL. - **url** (str) - The final URL after redirects. #### Response Example ```json { "status": 200, "content": [ "Extracted content line 1", "Extracted content line 2" ], "url": "https://example.com" } ``` ``` -------------------------------- ### Scrapling GET Request with Cookies Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/SKILL.md Demonstrates sending a GET request with custom cookies. This is essential for accessing content that requires authentication or session management. ```bash scrapling extract get "https://scrapling.requestcatcher.com" content.md --cookies "session=abc123; user=john" ``` -------------------------------- ### Create PDFs with reportlab Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/pdf/SKILL.md Demonstrates creating new PDF documents from scratch, including adding text, lines, and multi-page layouts using reportlab. ```python from reportlab.lib.pagesizes import letter from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, PageBreak from reportlab.lib.styles import getSampleStyleSheet doc = SimpleDocTemplate("report.pdf", pagesize=letter) styles = getSampleStyleSheet() story = [] story.append(Paragraph("Report Title", styles['Title'])) story.append(Spacer(1, 12)) story.append(Paragraph("This is the body of the report.", styles['Normal'])) story.append(PageBreak()) doc.build(story) ``` -------------------------------- ### Scrapling GET Request with Multiple Headers Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/SKILL.md Illustrates adding multiple custom HTTP headers to a GET request. This is useful for setting various request attributes like 'Accept' and 'Accept-Language'. ```bash scrapling extract get "https://site.com" page.html -H "Accept: text/html" -H "Accept-Language: en-US" ``` -------------------------------- ### Scrapling GET Request with Custom Header Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/SKILL.md Shows how to add a custom HTTP header, such as a User-Agent, to a GET request. This can be used to mimic specific clients or provide additional information to the server. ```bash scrapling extract get "https://api.site.com" data.json -H "User-Agent: MyBot 1.0" ``` -------------------------------- ### Configure QQ Integration Source: https://github.com/kdaip/echobot/blob/main/README_EN.md Sets up the QQ platform integration by providing the AppID and Client Secret in the channels.json configuration file. ```json "enabled": true "app_id": "your AppID", "client_secret": "your AppSecret" ``` -------------------------------- ### Implement Proxy Rotation with FetcherSession Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/references/fetching/static.md Demonstrates how to integrate ProxyRotator with a session to automatically cycle through a list of proxies for subsequent requests. ```python from scrapling.fetchers import FetcherSession, ProxyRotator rotator = ProxyRotator(['http://proxy1:8080', 'http://proxy2:8080']) with FetcherSession(proxy_rotator=rotator) as session: page1 = session.get('https://example.com/page1') page2 = session.get('https://example.com/page2') ``` -------------------------------- ### Scrapling GET Request with Custom Timeout Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/SKILL.md Shows how to specify a custom timeout for a GET request. This is useful when dealing with slow-loading pages or when you need to control how long the request should wait before failing. ```bash scrapling extract get "https://example.com" content.txt --timeout 60 ``` -------------------------------- ### Manage Persistent Sessions with FetcherSession Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/references/fetching/static.md Explains how to use FetcherSession to maintain configuration, cookies, and connection pools across multiple requests. Demonstrates session-wide settings and per-request overrides. ```python from scrapling.fetchers import FetcherSession with FetcherSession(impersonate='chrome', http3=True) as session: page1 = session.get('https://scrapling.requestcatcher.com/get') page2 = session.post('https://scrapling.requestcatcher.com/post', data={'key': 'value'}) ``` -------------------------------- ### GET /spider/results Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/references/spiders/advanced.md Retrieves the final results and comprehensive statistics after a crawl has completed. ```APIDOC ## GET /spider/results ### Description Returns a CrawlResult object containing all scraped items and detailed performance metrics. ### Method GET ### Endpoint /spider/results ### Response #### Success Response (200) - **items** (array) - List of all scraped items. - **stats** (object) - Detailed crawl statistics including request counts, error rates, and timing. - **completed** (boolean) - Whether the crawl finished successfully. #### Response Example { "items": [], "stats": { "requests_count": 150, "items_scraped": 100, "elapsed_seconds": 45.5 }, "completed": true } ``` -------------------------------- ### GET /fetcher/standard Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/SKILL.md Performs standard HTTP requests with session support and TLS fingerprinting. ```APIDOC ## GET /fetcher/standard ### Description Performs a standard HTTP request using a session with Chrome TLS fingerprinting or a one-off request. ### Method GET ### Parameters #### Request Body - **impersonate** (string) - Optional - TLS fingerprinting version (e.g., 'chrome') - **stealthy_headers** (boolean) - Optional - Whether to use stealth headers ### Request Example ```python with FetcherSession(impersonate='chrome') as session: page = session.get('https://quotes.toscrape.com/', stealthy_headers=True) ``` ### Response #### Success Response (200) - **page** (object) - The response object containing CSS/XPath selection methods. ``` -------------------------------- ### Pack Presentation Files with Python Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/pptx/editing.md This script repacks the unpacked presentation files back into a valid PPTX file. It includes validation and repair steps, condenses the XML, and re-encodes smart quotes. It can use an original presentation file for comparison or to preserve certain aspects. ```bash python scripts/office/pack.py unpacked/ output.pptx --original input.pptx ``` -------------------------------- ### GET /spider/stream Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/references/spiders/advanced.md Streams scraped items in real-time as they are processed, allowing for immediate data access and monitoring. ```APIDOC ## GET /spider/stream ### Description Initiates a real-time stream of scraped items. This method must be called from an async context and allows for monitoring of spider statistics during the crawl. ### Method GET ### Endpoint /spider/stream ### Parameters #### Query Parameters - **crawldir** (string) - Optional - Path to the checkpoint directory for resuming crawls. ### Response #### Success Response (200) - **item** (object) - The scraped data item yielded in real-time. #### Response Example { "item": {"title": "Example Title", "url": "https://example.com"} } ``` -------------------------------- ### EchoBot AgentCore - Python Source: https://context7.com/kdaip/echobot/llms.txt Demonstrates the usage of the AgentCore, the central engine of EchoBot, supporting tool invocation and skill systems. It shows basic Q&A, streaming responses, and integrating custom tools for enhanced agent capabilities. Requires an OpenAI API key and a compatible model. ```python from echobot.agent import AgentCore from echobot.providers.openai_provider import OpenAIProvider from echobot.tools.base import ToolRegistry, BaseTool # 创建 LLM 提供商 provider = OpenAIProvider( api_key="your-api-key", model="gpt-4o-mini", base_url="https://api.openai.com/v1" ) # 创建 Agent agent = AgentCore( provider, system_prompt="你是一个友好的AI助手。" ) # 简单问答 response = await agent.ask( "今天天气怎么样?", temperature=0.7, max_tokens=1024 ) print(response.message.content) # 流式输出 async for chunk in agent.ask_stream("给我讲个故事"): print(chunk, end="", flush=True) # 带工具的调用 class WeatherTool(BaseTool): name = "get_weather" description = "获取指定城市的天气" parameters = { "type": "object", "properties": { "city": {"type": "string", "description": "城市名称"} }, "required": ["city"] } async def run(self, city: str) -> str: return f"{city}今天晴天,温度25°C" tool_registry = ToolRegistry() tool_registry.register(WeatherTool()) result = await agent.ask_with_tools( "北京今天天气怎么样?", tool_registry=tool_registry, max_steps=10 ) print(result.response.message.content) print(f"执行步骤: {result.steps}") ``` -------------------------------- ### POST /bulk_get Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/references/mcp-server.md Performs concurrent HTTP GET requests to multiple URLs, returning a list of responses. ```APIDOC ## POST /bulk_get ### Description Asynchronous concurrent version of the `get` tool. Fetches multiple URLs in parallel. ### Method POST ### Endpoint /bulk_get ### Parameters #### Request Body - **urls** (list of str) - Required - A list of URLs to fetch. - **extraction_type** (str) - Optional - Output format for each URL. Allowed values: "markdown", "html", "text". Default: "markdown" - **css_selector** (str) - Optional - CSS selector to narrow content for each URL. - **main_content_only** (bool) - Optional - Restrict to `` content for each URL. Default: true - **impersonate** (str) - Optional - Browser fingerprint to impersonate for each request. Default: "chrome" - **proxy** (str) - Optional - Proxy URL to use for all requests. - **proxy_auth** (dict) - Optional - Proxy authentication details for all requests. - **auth** (dict) - Optional - HTTP basic authentication details for all requests. - **timeout** (number) - Optional - Seconds before timeout for each request. Default: 30 - **retries** (int) - Optional - Retry attempts on failure for each request. Default: 3 - **retry_delay** (int) - Optional - Seconds between retries for each request. Default: 1 - **stealthy_headers** (bool) - Optional - Generate realistic browser headers and Google referer. Default: true - **http3** (bool) - Optional - Use HTTP/3 for each request. Default: false - **follow_redirects** (bool) - Optional - Follow HTTP redirects for each request. Default: true - **max_redirects** (int) - Optional - Max redirects for each request. Default: 30 - **headers** (dict) - Optional - Custom request headers for each request. - **cookies** (dict) - Optional - Request cookies for each request. - **params** (dict) - Optional - Query string parameters for each request. - **verify** (bool) - Optional - Verify HTTPS certificates for each request. Default: true ### Request Example ```json { "urls": [ "https://example.com/page1", "https://example.com/page2" ], "extraction_type": "text", "css_selector": ".article-content" } ``` ### Response #### Success Response (200) - **responses** (list of ResponseModel) - A list of response objects, one for each URL requested. **ResponseModel Fields:** - **status** (int) - The status code of the response. - **content** (list of str) - The extracted content from the URL. - **url** (str) - The final URL after redirects. #### Response Example ```json { "responses": [ { "status": 200, "content": ["Content from page 1"] "url": "https://example.com/page1" }, { "status": 404, "content": [] "url": "https://example.com/page2" } ] } ``` ``` -------------------------------- ### Configure Cloudflare Solving and Stealth Options Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/references/fetching/stealthy.md Demonstrates how to enable automatic Cloudflare challenge solving and apply various stealth configurations like proxy settings, WebRTC blocking, and canvas hiding to evade detection. ```python # Automatic Cloudflare solver page = StealthyFetcher.fetch('https://nopecha.com/demo/cloudflare', solve_cloudflare=True) # Works with other stealth options page = StealthyFetcher.fetch( 'https://protected-site.com', solve_cloudflare=True, block_webrtc=True, real_chrome=True, hide_canvas=True, google_search=True, proxy='http://username:password@host:port', ) ``` -------------------------------- ### Get Available Roles - EchoBot API Source: https://context7.com/kdaip/echobot/llms.txt Retrieves a list of all available character roles, indicating whether they are editable or deletable. ```bash curl http://127.0.0.1:8000/roles ``` ```json [ { "name": "default", "editable": false, "deletable": false, "source_path": null }, { "name": "tsundere", "editable": true, "deletable": true, "source_path": ".echobot/roles/tsundere.md" } ] ``` -------------------------------- ### Fetch URL with Real Chrome Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/references/fetching/dynamic.md Fetches a page using a locally installed Google Chrome browser for improved authenticity and reduced detectability. ```python DynamicFetcher.fetch('https://example.com', real_chrome=True) ``` -------------------------------- ### Get Web Console Configuration - Echobot API Source: https://context7.com/kdaip/echobot/llms.txt Retrieves the complete configuration for the Web console, encompassing settings for Live2D, TTS, and ASR services. ```bash curl http://127.0.0.1:8000/web/config ``` -------------------------------- ### Get Cron Jobs List - Echobot API Source: https://context7.com/kdaip/echobot/llms.txt Fetches a list of all scheduled cron jobs. Supports an option to include disabled jobs in the response. ```bash curl http://127.0.0.1:8000/cron/jobs curl "http://127.0.0.1:8000/cron/jobs?include_disabled=true" ``` -------------------------------- ### POST /fetch Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/references/fetching/dynamic.md Fetches a dynamic website using various browser automation strategies. ```APIDOC ## POST /fetch ### Description Fetches the content of a dynamic website by launching or connecting to a browser instance. ### Method POST ### Endpoint /fetch ### Parameters #### Query Parameters - **url** (string) - Required - The target website URL to fetch. - **real_chrome** (boolean) - Optional - If true, uses the installed Google Chrome browser instead of Chromium. - **cdp_url** (string) - Optional - The WebSocket URL to connect to a remote browser via Chrome DevTools Protocol. ### Request Example { "url": "https://example.com", "real_chrome": true } ### Response #### Success Response (200) - **page** (object) - Returns a Playwright Page object for further interaction. #### Response Example { "status": "success", "message": "Page loaded successfully" } ``` -------------------------------- ### Get Session List - EchoBot API Source: https://context7.com/kdaip/echobot/llms.txt Retrieves a list of all available chat sessions, including their names, message counts, and last updated timestamps. ```bash curl http://127.0.0.1:8000/sessions ``` ```json [ { "name": "default", "message_count": 42, "updated_at": "2024-01-15T10:30:00Z" }, { "name": "coding", "message_count": 15, "updated_at": "2024-01-14T20:00:00Z" } ] ``` -------------------------------- ### Scrapling CLI - Shared Request Options Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/SKILL.md This section details the common options applicable to all HTTP request commands in Scrapling, such as GET, POST, PUT, and DELETE. ```APIDOC ## Shared Request Options ### Description These options are shared across all four HTTP request commands (GET, POST, PUT, DELETE) in Scrapling, allowing for customization of request behavior and data handling. ### Options #### Common Options - **-H, --headers** (TEXT) - HTTP headers in format "Key: Value" (can be used multiple times). - **--cookies** (TEXT) - Cookies string in format "name1=value1; name2=value2". - **--timeout** (INTEGER) - Request timeout in seconds (default: 30). - **--proxy** (TEXT) - Proxy URL in format "http://username:password@host:port". - **-s, --css-selector** (TEXT) - CSS selector to extract specific content from the page. It returns all matches. - **-p, --params** (TEXT) - Query parameters in format "key=value" (can be used multiple times). - **--follow-redirects / --no-follow-redirects** (None) - Whether to follow redirects (default: True). - **--verify / --no-verify** (None) - Whether to verify SSL certificates (default: True). - **--impersonate** (TEXT) - Browser to impersonate. Can be a single browser (e.g., Chrome) or a comma-separated list for random selection (e.g., Chrome, Firefox, Safari). - **--stealthy-headers / --no-stealthy-headers** (None) - Use stealthy browser headers (default: True). ### Request Example ```bash scrapling extract get "https://example.com" content.txt --timeout 60 -H "User-Agent: MyBot 1.0" ``` ``` -------------------------------- ### EchoBot SkillRegistry - Python Source: https://context7.com/kdaip/echobot/llms.txt Illustrates how to use the SkillRegistry for dynamic loading and management of specialized workflows within EchoBot. It covers discovering skills, checking for warnings, retrieving skill information, and integrating skills with the AgentCore for complex task execution. ```python from echobot.skill_support import SkillRegistry # 自动发现并加载技能 skill_registry = SkillRegistry.discover( project_root=".", client_name="echobot" ) # 查看可用技能 print("可用技能:", skill_registry.names()) # 检查技能加载警告 for warning in skill_registry.warnings: print(f"警告: {warning}") # 获取技能信息 pdf_skill = skill_registry.get("pdf") if pdf_skill: print(f"技能名称: {pdf_skill.name}") print(f"技能描述: {pdf_skill.description}") # 结合 Agent 使用技能 result = await agent.ask_with_skills( "帮我把 report.pdf 转换为文本", skill_registry=skill_registry, tool_registry=tool_registry, max_steps=20 ) ``` -------------------------------- ### Get Heartbeat Configuration - Echobot API Source: https://context7.com/kdaip/echobot/llms.txt Retrieves the configuration and content of the heartbeat task. This includes whether it's enabled, its interval, and associated file path and content. ```bash curl http://127.0.0.1:8000/heartbeat ``` -------------------------------- ### AgentCore - Core Agent Engine Source: https://context7.com/kdaip/echobot/llms.txt Demonstrates the usage of AgentCore for core AI functionalities, including simple Q&A, streaming responses, and tool-assisted actions. ```APIDOC ## AgentCore - Core Agent Engine ### Description AgentCore is the central engine for EchoBot, supporting tool invocation and skill systems. This example shows basic usage, streaming, and tool integration. ### Usage ```python from echobot.agent import AgentCore from echobot.providers.openai_provider import OpenAIProvider from echobot.tools.base import ToolRegistry, BaseTool # Initialize LLM provider provider = OpenAIProvider( api_key="your-api-key", model="gpt-4o-mini", base_url="https://api.openai.com/v1" ) # Create Agent instance agent = AgentCore( provider, system_prompt="You are a friendly AI assistant." ) # Simple question answering response = await agent.ask( "What is the weather today?", temperature=0.7, max_tokens=1024 ) print(response.message.content) # Streaming output async for chunk in agent.ask_stream("Tell me a story"): print(chunk, end="", flush=True) # Tool-assisted invocation class WeatherTool(BaseTool): name = "get_weather" description = "Get the weather for a specified city" parameters = { "type": "object", "properties": { "city": {"type": "string", "description": "City name"} }, "required": ["city"] } async def run(self, city: str) -> str: return f"{city} is sunny today with a temperature of 25°C" tool_registry = ToolRegistry() tool_registry.register(WeatherTool()) result = await agent.ask_with_tools( "What is the weather in Beijing today?", tool_registry=tool_registry, max_steps=10 ) print(result.response.message.content) print(f"Execution steps: {result.steps}") ``` ``` -------------------------------- ### Get Current Session Details - EchoBot API Source: https://context7.com/kdaip/echobot/llms.txt Retrieves detailed information about the currently active session, including its name, summary, configuration, and full conversation history. ```bash curl http://127.0.0.1:8000/sessions/current ``` ```json { "name": "default", "updated_at": "2024-01-15T10:30:00Z", "compressed_summary": "用户询问了天气和日程安排", "role_name": "default", "route_mode": "auto", "history": [ {"role": "user", "content": "早上好"}, {"role": "assistant", "content": "早上好呀~"} ] } ``` -------------------------------- ### Get Available TTS Voices - Echobot API Source: https://context7.com/kdaip/echobot/llms.txt Retrieves a list of available voices for a given Text-to-Speech (TTS) provider. This helps in selecting appropriate voices for speech generation. ```bash curl "http://127.0.0.1:8000/web/tts/voices?provider=edge" ``` -------------------------------- ### Handle Pagination Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/references/fetching/static.md Shows a pattern for iterating through multiple pages of content until no more products are found. ```python from scrapling.fetchers import Fetcher def scrape_all_pages(): base_url = 'https://example.com/products?page={}' page_num = 1 all_products = [] while True: page = Fetcher.get(base_url.format(page_num)) products = page.css('.product') if not products: break for product in products: all_products.append({'name': product.css('.name::text').get()}) page_num += 1 return all_products ``` -------------------------------- ### Define Slide Master with Placeholders Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/pptx/pptxgenjs.md Demonstrates how to define a slide master with a title placeholder and instantiate a slide using that master. ```javascript pres.defineSlideMaster({ title: 'TITLE_SLIDE', background: { color: '283A5E' }, objects: [{ placeholder: { options: { name: 'title', type: 'title', x: 1, y: 2, w: 8, h: 2 } } }] }); let titleSlide = pres.addSlide({ masterName: "TITLE_SLIDE" }); titleSlide.addText("My Title", { placeholder: "title" }); ``` -------------------------------- ### Get Cron Status - Echobot API Source: https://context7.com/kdaip/echobot/llms.txt Retrieves the current operational status of the cron job service. Includes information on whether the service is enabled and the number of active jobs. ```bash curl http://127.0.0.1:8000/cron/status ``` -------------------------------- ### Correct Color Formatting Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/pptx/pptxgenjs.md Shows the correct way to specify hex colors without the '#' prefix to avoid file corruption. ```javascript color: "FF0000" // ✅ CORRECT color: "#FF0000" // ❌ WRONG ``` -------------------------------- ### Get the Number of Selector Instances Source: https://github.com/kdaip/echobot/blob/main/echobot/skills/scrapling/references/parsing/main_classes.md Shows how to retrieve the total number of Selector instances within a Selectors instance. This can be done using the '.length' property or the standard Python 'len()' function. ```python page.css('.product_pod').length which is equivalent to len(page.css('.product_pod')) ```