An integration package connecting Cloudsway and LangChain
Project description
langchain-cloudsway
This package contains the LangChain integration with Cloudsway.
Installation
pip install -U langchain-cloudsway
Configuration
Set your Cloudsway API credentials as an environment variable:
export CLOUDSWAY_SERVER_KEY="your-endpoint-accesskey"
The value should be in the format:
endpoint-accesskey
To get your token and subscribe to a plan, please register at console.cloudsway.ai.
Tool
SmartsearchTool provides web search via the Cloudsway API.
Basic Usage
from langchain_cloudsway.smartsearch import SmartsearchTool
tool = SmartsearchTool()
result = tool.invoke({
"query": "cloudsway.ai",
"count": 5,
"setLang": "en"
})
print(result)
Available Parameters
The SmartsearchTool supports the following parameters:
| Parameter | Required | Type | Description |
|---|---|---|---|
| query (q) | Yes | String | The search query string. Cannot be empty. |
| count | No | Short | Number of search results to return. Default: 10, Maximum: 50. Accepted values: 10, 20, 30, 40, 50. |
| freshness | No | String | Filter results by time period: "Day", "Week", "Month", or a date range like "2023-02-01..2023-05-30". |
| offset | No | Short | Zero-based offset indicating how many results to skip. Default: 0. |
| setLang | No | String | Language code for results (recommended to use 4-letter codes like "en-US"). Default: "en". |
| sites | No | String | Host address to filter results from a specific website (e.g., "baijiahao.baidu.com"). |
Advanced Usage Examples
# Search with freshness filter
result = tool.invoke({
"query": "latest AI research",
"count": 20,
"freshness": "Week",
"setLang": "en-US"
})
# Search within a specific site
result = tool.invoke({
"query": "machine learning tutorial",
"sites": "github.com"
})
# Paginated search
result = tool.invoke({
"query": "climate change",
"count": 10,
"offset": 10 # Get second page of results
})
Response Structure
The API returns a JSON response with the following structure:
{
"queryContext": {
"originalQuery": "your search query"
},
"webPages": {
"value": [
{
"name": "Page Title",
"url": "https://example.com/page",
"displayUrl": "https://example.com/page",
"snippet": "Description of the page content...",
"datePublished": "2025-07-14T00:00:00.0000000",
"dateLastCrawled": "2025-07-15T02:48:00.0000000Z",
"siteName": "Example Website",
"thumbnailUrl": "https://example.com/thumbnail.jpg",
"score": 0.95
},
// Additional results...
]
}
}
Response Fields
-
queryContext: Contains information about the search query
- originalQuery: The search term used in the request
-
webPages.value: Array of search result objects, each containing:
- name: Title of the webpage
- url: URL of the webpage
- displayUrl: URL displayed for the result
- snippet: Brief description of the webpage content
- datePublished: Publication date (when available)
- dateLastCrawled: Date when the page was last indexed
- siteName: Name of the website (when available)
- thumbnailUrl: URL to thumbnail image (when available)
- score: Relevance score (when available)
Error Handling
The API may return the following status codes:
- 200: Successful request
- 429: Rate limit exceeded (QPS limit reached)
For higher QPS limits, please contact Cloudsway support.
License
This project is open-sourced under the MIT License. See LICENSE for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_cloudsway-0.1.1.tar.gz.
File metadata
- Download URL: langchain_cloudsway-0.1.1.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77e2bf23854128ad9c1fdd85d9d123b90d5d632dd9eebaafa3c57a09bc6a96cb
|
|
| MD5 |
f400157a0307bae494e74a563a11710d
|
|
| BLAKE2b-256 |
0d607cb03090abc9a73cda81cd9f411d2943b7a958f581d4aeff2ddb3b8d0534
|
File details
Details for the file langchain_cloudsway-0.1.1-py3-none-any.whl.
File metadata
- Download URL: langchain_cloudsway-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
76df2a572598420c591929ef67fbab52167855b87c64a66f5747ff853f27eb1e
|
|
| MD5 |
ca3c65f21364552ea6850d8c195ee0dd
|
|
| BLAKE2b-256 |
03450c10608bdec20b4eec8a243fbbebc9e3c09653bea66a849dc960b89ea090
|