Demonstrates how curllm handles currency conversion for price filters.
When searching Polish e-commerce sites like ceneo.pl with:
curllm "https://ceneo.pl" -d "Extract products under $100"
The site uses PLN (złoty), but user specified USD. Without translation:
The CurrencyTranslator component automatically:
.pl domain)from curllm_core.streamware.components.currency import convert_price, detect_currency
# Simple conversion
pln_amount = convert_price(100, "USD", "PLN")
print(f"$100 = {pln_amount:.0f} zł") # $100 = 405 zł
# Detect currency from URL
currency = detect_currency("https://ceneo.pl")
print(f"Site currency: {currency}") # PLN
from curllm_core.streamware.components.currency import normalize_price_filter
# Normalize instruction filter
instruction = "Extract products under $100"
_, filter_info = normalize_price_filter(instruction, target_currency="PLN")
print(filter_info)
# {
# "amount": 100,
# "currency": "USD",
# "comparison": "lt",
# "amount_converted": 405.0,
# "target_currency": "PLN"
# }
import asyncio
from curllm_core.streamware.components.currency import CurrencyTranslator
async def main():
translator = CurrencyTranslator()
# With Playwright page
instruction = "Find laptops under €500"
modified, filter_info = await translator.normalize_filter_to_page_currency(
instruction,
page=playwright_page, # Auto-detects currency from page
)
print(f"Original: €500")
print(f"Converted: {filter_info['amount_converted']:.0f} {filter_info['target_currency']}")
asyncio.run(main())
| Symbol | Code | Example |
|---|---|---|
| $ | USD | $100 |
| € | EUR | €100 |
| zł | PLN | 100 zł |
| £ | GBP | £100 |
| Kč | CZK | 100 Kč |
| kr | SEK | 100 kr |
| Ft | HUF | 100 Ft |
Default rates are built-in. For live rates, set:
export EXCHANGE_RATE_API_KEY="your_api_key"
| File | Description |
|---|---|
currency_example.py |
Full example with page detection |
simple_conversion.py |
Basic conversion examples |