An integration package connecting Cloro.dev and LangChain
Project description
langchain-cloro
This package contains the LangChain integration for cloro.dev - a unified API for monitoring multiple AI providers including Google Search, ChatGPT, Gemini, Perplexity, Grok, and Microsoft Copilot.
Installation
pip install langchain-cloro
Setup
You'll need a cloro API key. Get one at https://cloro.dev.
Set the API key as an environment variable:
export CLORO_API_KEY="your-api-key-here"
Or pass it directly when initializing:
from langchain_cloro import CloroGoogleSearch
tool = CloroGoogleSearch(cloro_api_key="your-api-key-here")
Available Tools
CloroGoogleSearch
Extract structured data from Google Search results, including organic results, People Also Ask questions, related searches, and optional AI Overview data.
from langchain_cloro import CloroGoogleSearch
tool = CloroGoogleSearch()
# Basic search
results = tool.invoke({"query": "best laptops for programming"})
# With AI Overview
results = tool.invoke({
"query": "best laptops for programming",
"include_aioverview": True,
"aioverview_markdown": True
})
# Multiple pages
results = tool.invoke({
"query": "python tutorials",
"pages": 3,
"country": "US",
"device": "desktop"
})
Parameters:
query(str, required): The search querycountry(str): ISO 3166-1 alpha-2 country code. Default: "US"device(str): "desktop" or "mobile". Default: "desktop"pages(int): Number of pages to scrape (1-20). Default: 1include_aioverview(bool): Include Google AI Overview. Default: Falseaioverview_markdown(bool): Format AI Overview as markdown. Default: Falseinclude_html(bool): Include raw HTML response. Default: False
CloroChatGPT
Extract structured data from ChatGPT with shopping cards, entity extraction, and advanced features for monitoring products, prices, and brand mentions.
from langchain_cloro import CloroChatGPT
tool = CloroChatGPT()
# Basic query
results = tool.invoke({"prompt": "What are the best sneakers under $100?"})
# With shopping card data
results = tool.invoke({
"prompt": "best running shoes",
"include_raw_response": True,
"include_search_queries": True
})
Parameters:
prompt(str, required): The prompt/querycountry(str): ISO 3166-1 alpha-2 country code. Default: "US"include_raw_response(bool): Include raw streaming response events. Default: Falseinclude_search_queries(bool): Include search fan-out queries. Default: Falseinclude_html(bool): Include HTML response. Default: Falseinclude_markdown(bool): Include markdown response. Default: False
CloroGemini
Extract structured data from Google's Gemini AI with source citations, confidence levels, and multiple output formats.
from langchain_cloro import CloroGemini
tool = CloroGemini()
results = tool.invoke({"prompt": "Explain quantum entanglement"})
Parameters:
prompt(str, required): The prompt/querycountry(str): ISO 3166-1 alpha-2 country code. Default: "US"include_html(bool): Include HTML response. Default: Falseinclude_markdown(bool): Include markdown response. Default: False
CloroPerplexity
Extract comprehensive structured data from Perplexity AI with real-time web sources, shopping products, media content, and travel information.
from langchain_cloro import CloroPerplexity
tool = CloroPerplexity()
# Travel query
results = tool.invoke({"prompt": "Best hotels in San Francisco"})
# Shopping query
results = tool.invoke({"prompt": "best noise-cancelling headphones"})
Parameters:
prompt(str, required): The prompt/querycountry(str): ISO 3166-1 alpha-2 country code. Default: "US"include_html(bool): Include HTML response. Default: Falseinclude_markdown(bool): Include markdown response. Default: False
CloroGrok
Extract comprehensive structured data from Grok with real-time web sources and enhanced source metadata including preview text, creator details, and images.
from langchain_cloro import CloroGrok
tool = CloroGrok()
results = tool.invoke({"prompt": "Latest news about AI"})
Parameters:
prompt(str, required): The prompt/querycountry(str): ISO 3166-1 alpha-2 country code. Default: "US"include_html(bool): Include HTML response. Default: Falseinclude_markdown(bool): Include markdown response. Default: False
CloroCopilot
Extract structured data from Microsoft Copilot with source citations.
from langchain_cloro import CloroCopilot
tool = CloroCopilot()
results = tool.invoke({"prompt": "What is the capital of France?"})
Parameters:
prompt(str, required): The prompt/querycountry(str): ISO 3166-1 alpha-2 country code. Default: "US"include_html(bool): Include HTML response. Default: Falseinclude_markdown(bool): Include markdown response. Default: False
get_countries Utility
Get list of supported country codes for specific AI providers.
from langchain_cloro import get_countries
# Get all countries
all_countries = get_countries()
# Get countries for specific model
chatgpt_countries = get_countries(model="chatgpt")
google_countries = get_countries(model="google")
Usage with LangChain Agents
With an Agent
from langchain.agents import initialize_agent, AgentType
from langchain_openai import OpenAI
from langchain_cloro import CloroGoogleSearch, CloroChatGPT
llm = OpenAI(temperature=0)
tools = [CloroGoogleSearch(), CloroChatGPT()]
agent = initialize_agent(
tools,
llm,
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
verbose=True,
)
agent.run("What are the latest developments in AI?")
With LCEL
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
from langchain_openai import ChatOpenAI
from langchain_cloro import CloroChatGPT
chatgpt = CloroChatGPT()
prompt = ChatPromptTemplate.from_messages([
("system", "Answer based on the AI's response:\n\n{response}"),
("user", "{question}")
])
chain = {
"response": lambda x: chatgpt.invoke({"prompt": x["question"]}),
"question": lambda x: x["question"]
} | prompt | ChatOpenAI() | StrOutputParser()
response = chain.invoke({"question": "What is LangChain?"})
print(response)
Multiple Tools Example
from langchain_cloro import (
CloroGoogleSearch,
CloroChatGPT,
CloroGemini,
CloroPerplexity,
CloroGrok,
CloroCopilot
)
tools = [
CloroGoogleSearch(), # For search queries
CloroChatGPT(), # For shopping/product queries
CloroGemini(), # For general AI queries
CloroPerplexity(), # For research with citations
CloroGrok(), # For real-time news
CloroCopilot(), # For general queries
]
Supported Country Codes
Use the get_countries() utility to fetch supported countries:
from langchain_cloro import get_countries
# Check which countries are available for each model
models = ["google", "chatgpt", "gemini", "perplexity", "grok", "copilot"]
for model in models:
countries = get_countries(model=model)
print(f"{model}: {len(countries)} countries")
Development
Running Tests
# Unit tests
pytest tests/unit_tests -v
# Linting
ruff check .
ruff format .
# Type checking
mypy langchain_cloro
API Reference
For detailed API documentation, see https://docs.cloro.dev.
License
MIT
Links
- Documentation: https://docs.cloro.dev
- Source: https://github.com/cloro-dev/langchain-cloro
- cloro API: https://cloro.dev
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_cloro-0.2.1.tar.gz.
File metadata
- Download URL: langchain_cloro-0.2.1.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a94f3c4f179eb4e26d9860b980971f7389f50dd0783969b36bfd84d4b1699edf
|
|
| MD5 |
4f0a160ce4c468a3e63cdac6094fadce
|
|
| BLAKE2b-256 |
d7ae6e0b2928be25c20e2eeef003b6d151c64d6e7d13a3d3809a7ed8e26c4429
|
File details
Details for the file langchain_cloro-0.2.1-py3-none-any.whl.
File metadata
- Download URL: langchain_cloro-0.2.1-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a48cb14683e6f459b9977b7d3ff7dfe37741826447fe05f584ddb2bf67072890
|
|
| MD5 |
4a943bd0ffc53862891df4da84001038
|
|
| BLAKE2b-256 |
a98b585712cdffbf1342295183ba3e315e81bce0cc31fd257229475e00a9e19d
|