Skip to main content

cityengine-tools

CityEngine Cloud 的 OpenAI 兼容 function-calling 适配层。把 6 个云端能力 (generate_cga / parse_cga / generate_model / list_demos / get_demo / get_quota) 导出为标准 OpenAI tools JSON schema,任何支持 function calling 的模型 (deepseek / qwen / glm / 混元 / gpt / 文心……)都能直接调用。

  • 网关契约:openapi-v1.yaml(参数名/类型/必填与其一致)
  • 鉴权:X-API-Key 头,cvk_ 前缀插件 key(https://www.cityengine.cn 用户中心签发)
  • 与 cityengine-mcp(MCP server)共用同一套网关端点,本包面向无 MCP 客户端的模型

安装

pip install cityengine-tools   # 或本地:pip install ./cityengine-tools

最小用法(任意 OpenAI 兼容模型)

import json, os
from openai import OpenAI
from cityengine_tools import TOOLS, call_tool

client = OpenAI(api_key=os.environ["MODEL_API_KEY"], base_url="<模型服务商的 OpenAI 兼容地址>")
msgs = [{"role": "user", "content": "用工具查一下我当前的 CityEngine 额度"}]
resp = client.chat.completions.create(model="<model>", messages=msgs, tools=TOOLS)
msg = resp.choices[0].message
msgs.append(msg)
for tc in msg.tool_calls or []:
    result = call_tool(tc.function.name, json.loads(tc.function.arguments))
    msgs.append({"role": "tool", "tool_call_id": tc.id, "content": json.dumps(result, ensure_ascii=False)})
print(client.chat.completions.create(model="<model>", messages=msgs).choices[0].message.content)

CITYENGINE_API_KEY 环境变量提供 CityEngine 插件 key(也可 call_tool(..., api_key="cvk_...") 显式传入)。

各模型现成示例见 examples/:deepseek、qwen(dashscope 兼容模式)、glm(智谱)、hunyuan(腾讯,未实测)。

工具一览

工具 网关端点 说明
generate_cga POST /v1/nl2cga 一句话 → CGA 源码(同步,不渲染)
parse_cga POST /v1/generate CGA + 属性 → glTF/glb(异步 job,自动轮询)
generate_model POST /v1/nl2model 一句话 → 三维模型(一键,异步 job)
list_demos GET www.cityengine.cn/home-demos.json 官网首页 demo 清单
get_demo GET home-scenes/{id}.json demo 属性面板/规模快照
get_quota GET /v1/account/quota 额度与限流查询

全部只读计算型端点,无任何写操作。call_tool 额外关键字参数(不进 schema): download_glb(默认 False,只回签名 URL)、output_dir、timeout_s。

REST 直连

不想装包的用户可按 openapi-v1.yaml 直接 HTTP 调用网关,能力等价。

Metadata

Release files for cityengine-tools 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cityengine-tools 0.1.0
File Size Uploaded Provenance Actions
cityengine_tools-0.1.0.tar.gz 7.7 kB Without provenance Details for cityengine_tools-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cityengine-tools 0.1.0
File Interpreter ABI Platform Actions
cityengine_tools-0.1.0-py3-none-any.whl Python 3 none any Details for cityengine_tools-0.1.0-py3-none-any.whl

Total release size: 16.4 kB

Release files / cityengine_tools-0.1.0.tar.gz

Download URL cityengine_tools-0.1.0.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
546cf92c22c907c84f6dbb3c1771691c8cb727a292d9661492c8f9806906a110
BLAKE2b-256 checksum
How to use checksums
620ac66e268903972032ccc8667c3e6b873e70b6fdc2dd6b3e6ffcc0550a763c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Release files / cityengine_tools-0.1.0-py3-none-any.whl

Download URL cityengine_tools-0.1.0-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31819b38e5144bdca29ae4684814d035bd083bf30f58ef5a0f79bfbee368bb27
BLAKE2b-256 checksum
How to use checksums
098f3bea15da7185730b4505af1705948adfdb6bf7222cd31a163c0c3f9d529f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Security for cityengine-tools 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page