local-places
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese📍 Local Places
📍 本地场所搜索
Find places, Go fast
Search for nearby places using a local Google Places API proxy. Two-step flow: resolve location first, then search.
快速查找场所
使用本地Google Places API代理搜索附近场所。分为两步流程:先解析位置,再进行搜索。
Setup
安装配置
bash
cd {baseDir}
echo "GOOGLE_PLACES_API_KEY=your-key" > .env
uv venv && uv pip install -e ".[dev]"
uv run --env-file .env uvicorn local_places.main:app --host 127.0.0.1 --port 8000Requires in or environment.
GOOGLE_PLACES_API_KEY.envbash
cd {baseDir}
echo "GOOGLE_PLACES_API_KEY=your-key" > .env
uv venv && uv pip install -e ".[dev]"
uv run --env-file .env uvicorn local_places.main:app --host 127.0.0.1 --port 8000需要在.env文件或环境变量中配置。
GOOGLE_PLACES_API_KEYQuick Start
快速开始
-
Check server:
curl http://127.0.0.1:8000/ping -
Resolve location:
bash
curl -X POST http://127.0.0.1:8000/locations/resolve \
-H "Content-Type: application/json" \
-d '{"location_text": "Soho, London", "limit": 5}'- Search places:
bash
curl -X POST http://127.0.0.1:8000/places/search \
-H "Content-Type: application/json" \
-d '{
"query": "coffee shop",
"location_bias": {"lat": 51.5137, "lng": -0.1366, "radius_m": 1000},
"filters": {"open_now": true, "min_rating": 4.0},
"limit": 10
}'- Get details:
bash
curl http://127.0.0.1:8000/places/{place_id}-
检查服务器:
curl http://127.0.0.1:8000/ping -
解析位置:
bash
curl -X POST http://127.0.0.1:8000/locations/resolve \
-H "Content-Type: application/json" \
-d '{"location_text": "Soho, London", "limit": 5}'- 搜索场所:
bash
curl -X POST http://127.0.0.1:8000/places/search \
-H "Content-Type: application/json" \
-d '{
"query": "coffee shop",
"location_bias": {"lat": 51.5137, "lng": -0.1366, "radius_m": 1000},
"filters": {"open_now": true, "min_rating": 4.0},
"limit": 10
}'- 获取详情:
bash
curl http://127.0.0.1:8000/places/{place_id}Conversation Flow
对话流程
- If user says "near me" or gives vague location → resolve it first
- If multiple results → show numbered list, ask user to pick
- Ask for preferences: type, open now, rating, price level
- Search with from chosen location
location_bias - Present results with name, rating, address, open status
- Offer to fetch details or refine search
- 如果用户说“在我附近”或给出模糊位置 → 先解析位置
- 如果有多个结果 → 显示编号列表,让用户选择
- 询问偏好:类型、是否营业、评分、价格等级
- 使用所选位置的进行搜索
location_bias - 展示结果,包含名称、评分、地址、营业状态
- 提供获取详情或优化搜索的选项
Filter Constraints
过滤条件限制
- : exactly ONE type (e.g., "restaurant", "cafe", "gym")
filters.types - : integers 0-4 (0=free, 4=very expensive)
filters.price_levels - : 0-5 in 0.5 increments
filters.min_rating - : boolean
filters.open_now - : 1-20 for search, 1-10 for resolve
limit - : must be > 0
location_bias.radius_m
- :必须是一种类型(例如“restaurant”、“cafe”、“gym”)
filters.types - :整数0-4(0=免费,4=非常昂贵)
filters.price_levels - :0-5,步长0.5
filters.min_rating - :布尔值
filters.open_now - :搜索请求为1-20,解析请求为1-10
limit - :必须大于0
location_bias.radius_m
Response Format
响应格式
json
{
"results": [
{
"place_id": "ChIJ...",
"name": "Coffee Shop",
"address": "123 Main St",
"location": { "lat": 51.5, "lng": -0.1 },
"rating": 4.6,
"price_level": 2,
"types": ["cafe", "food"],
"open_now": true
}
],
"next_page_token": "..."
}Use as in next request for more results.
next_page_tokenpage_tokenjson
{
"results": [
{
"place_id": "ChIJ...",
"name": "Coffee Shop",
"address": "123 Main St",
"location": { "lat": 51.5, "lng": -0.1 },
"rating": 4.6,
"price_level": 2,
"types": ["cafe", "food"],
"open_now": true
}
],
"next_page_token": "..."
}在下次请求中使用作为参数以获取更多结果。
next_page_tokenpage_token