1from sentence_transformers import SentenceTransformer
2
3# Download from the 🤗 Hub
4model = SentenceTransformer("sentence_transformers_model_id")
5# Run inference
6queries = [
7 'What are the steps to connect to the OCR Web Service using Membrane CLI?',
8]
9documents = [
10 'The OCR Web Service is designed to transform images containing text into machine-readable text formats, facilitating automation in data entry and document processing for developers and businesses. Utilizing the OCR Web Service enables various applications such as extraction of text from scanned documents and images in formats like PDFs. The service operates using the Membrane CLI, which abstracts the complexities of authentication and credential management, enabling developers to focus on integration rather than authorization setups. \n\n### Installation and Setup\n\nTo start using the OCR Web Service, developers must first install the Membrane CLI:\n- **Command:** `npm install -g @membranehq/cli` \nThis command installs the CLI globally, allowing the user to invoke it from any terminal session. \n\nAfter installation, the first-time setup of the CLI requires the user to log in by executing:\n- **Command:** `membrane login --tenant` \nThis command will launch a browser for authentication. In headless environments, the user can copy a printed URL to perform the login and complete it with a command including a code provided post-authentication.\n\n### Connecting to the OCR Web Service\n\nTo connect to the OCR Web Service, developers can create a new connection by:\n1. Searching for the OCR Web Service connector with:\n - **Command:** `membrane search ocr-web-service --elementType=connector --json` \n The response will contain details including the connector ID.\n2. Establishing a connection as follows:\n - **Command:** `membrane connect --connectorId=CONNECTOR_ID --json` \n This command will require the user to authenticate via a browser, with the output providing a new connection ID. \n\n### Managing Connections\n\nTo verify existing connections:\n- **Command:** `membrane connection list --json` \nThis will list all active connections and help identify if a previous OCR connection is established.\n\n### Searching and Running Actions\n\nFor querying available actions, users can execute:\n- **Command:** `membrane action list --intent=QUERY --connectionId=CONNECTION_ID --json` \nThis command returns action objects containing IDs and input schemas necessary for executing tasks.\n\nTo run a specific action, the command is:\n- **Command:** `membrane action run --connectionId=CONNECTION_ID ACTION_ID --json` \nParameters can be passed in JSON format using:\n- **Command:** `membrane action run --connectionId=CONNECTION_ID ACTION_ID --json --input "{ \\"key\\": \\"value\\" }"`\n\n### Proxying Requests\n\nIf pre-defined actions do not meet user needs, direct requests can be made to the OCR Web Service API via Membrane’s proxy:\n- **Command:** `membrane request CONNECTION_ID /path/to/endpoint`\nA range of options can be specified to modify the request, including HTTP method, headers, data payloads, and parameters via options flags.\n\n### Best Practices\n\nThe documentation emphasizes several best practices:\n- Rely on Membrane for interactions with external applications to leverage its built-in error handling, security, and token management features.\n- Explore available actions before attempting to create new API calls to save development time and prevent common mistakes.\n- Avoid asking users for API keys or credentials by managing authentication through Membrane directly.\n\nOverall, the OCR Web Service provides an encapsulated environment for efficiently handling image text extraction with robust support for ease of integration and security handling.',
11 'The 2Captcha skill provides developers and businesses with a practical means of bypassing CAPTCHA challenges on various web and application platforms using a service that outsources the solving of these CAPTCHAs to human workers. The skill operates through Membrane CLI, which facilitates interaction with the 2Captcha service while automating authentication, credential refresh, and HTTP header management to simplify integration. The main features include support for different types of CAPTCHAs (Image, ReCaptchaV2, ReCaptchaV3, GeeTest, HCaptcha, Turnstile, MtCaptcha, KeyCaptcha, Text), making it versatile for varied use cases.\n\n### Workflow Steps and Control Flow\n1. **CLI Installation:** Users start by installing the Membrane CLI, which is required to run commands that interact with 2Captcha. This is done using `npm install -g @membranehq/cli`.\n2. **Authentication Setup:** First-time users authenticate through a browser using the command `membrane login --tenant`. In headless environments, a unique URL is provided for manual completion.\n3. **Creating a 2Captcha Connection:** Users create a connection to the 2Captcha service using a specific connector ID, retrieved from a search command. The command `membrane connect --connectorId=CONNECTOR_ID --json` initiates this connection process.\n4. **Managing Connections:** To check existing connections, the command `membrane connection list --json` is used which lists all established connections. Users can note the `connectionId` for further actions.\n5. **Searching Actions:** To discover available actions based on intent, users can run `membrane action list --intent=QUERY --connectionId=CONNECTION_ID --json`, which returns a list of action objects with their IDs and schemas.\n6. **Running Actions:** Actions are executed using the command `membrane action run --connectionId=CONNECTION_ID ACTION_ID --json`, during which JSON parameters can be passed for specific configurations.\n7. **Proxy Requests:** When built-in actions do not suffice, developers can directly interact with the 2Captcha API using `membrane request CONNECTION_ID /path/to/endpoint`, along with various flags for HTTP methods, headers, and body data.\n\n### Required Tools and Environment Assumptions\n- Node.js environment (for the installation of Membrane CLI).\n- Access to a web browser for initial authentication, unless operating in a headless environment where manual interaction is feasible.\n\n### Command-Line Usage and Argument Behavior\n- **CLI Commands:** Predominantly utilize `membrane` commands in the terminal.\n- **Arguments:** Various commands accept flags and JSON input. For example, `--json` denotes that input will be in JSON format, while others specify HTTP methods and query parameters.\n\n### Input/Output Contracts and Data Formats\n- Input should conform to JSON schemas outlined in action descriptions.\n- Output format for commands generally includes JSON responses detailing the results of operations, such as connection ids, action ids, and any errors encountered.\n\n### Operational Caveats and Limitations\n- The skill highly recommends the use of Membrane for API interactions to minimize the risk of errors in direct API calls.\n- It is advisable to search for pre-built actions before creating custom API calls, as Membrane accounts for pagination and possible edge cases in handling API communications.\n- Each action may incur token usage, which could be limited depending on the specifics of the Membrane and 2Captcha service agreements.',
12 "The Server Health Skill is a command-line tool designed for quick server monitoring, providing insights into system statistics, processes, OpenClaw gateway information, and running services. It employs a script called `server-health.sh` that users can execute in their terminal. The tool offers various usage modes including standard view, verbose output, JSON format for automation, and alerts for warnings or errors based on system metrics.\n\n### Usage and Workflow\nUsers can run the script with different flags:\n- **Standard view**: `./server-health.sh` provides a basic overview of the server's status.\n- **Verbose mode**: `./server-health.sh --verbose` enriches the output by including additional details like temperature, network stats, swap usage, and I/O without requiring user interruptions.\n- **JSON output**: `./server-health.sh --json` sends output in JSON format, catering specifically to automation processes that require structured data handling.\n- **Alerts only**: `./server-health.sh --alerts` filters the output to show alerts related to resource usage (for instance, CPU, RAM, and disk thresholds).\n\n### Output Details\nThe outputs are structured into several sections:\n- **Always displayed** information includes system stats like CPU usage, RAM availability, disk usage, and server uptime. It lists the top processes by CPU and RAM consumption and shows the status and configuration of the OpenClaw gateway.\n- **Conditionally displayed** alerts trigger if resource usage exceeds predefined thresholds (i.e., disk >90%, RAM >80%, CPU >90%) or if swap space is in use.\n- **Verbose mode only** provides further details that can be vital for in-depth diagnostics like temperature readings (if sensor data is available), current network traffic, disk I/O rates, and specifics on running services.\n\n### Example Output\nAn example output provides a clear visual metric of server health, presenting the data in an easy-to-read style, spanning from general system health indicators to detailed process utilization and gateway status.\n\n### Operational Caveats and Limitations\nThis tool assumes a certain environment where the underlying system supports the required metrics (e.g., if temperature sensors are absent, temperature readings will not be shown). Additionally, monitoring accuracy depends on the correct configuration of the OpenClaw gateway and services like Docker and PostgreSQL that should be running on the system. The output formatting, especially in verbose mode, may depend on the terminal's capability to display special characters for better visualization.",
13]
14query_embeddings = model.encode_query(queries)
15document_embeddings = model.encode_document(documents)
16print(query_embeddings.shape, document_embeddings.shape)
17# [1, 1024] [3, 1024]
18
19# Get the similarity scores for the embeddings
20similarities = model.similarity(query_embeddings, document_embeddings)
21print(similarities)
22# tensor([[0.7668, 0.4454, 0.2444]])