Skip to content

Examples

sungaowei edited this page Oct 16, 2026 · 2 revisions

示例程序 (Examples)

English Version | 简体中文


完整且可运行的示例程序存放在官方代码仓库的 examples/ 目录下。

示例工程 演示内容
examples/quickstart 发起一次 SystemOne 评估调用,包含 Noul、Choice、Score 三种原语,格式化输出所有答案。
examples/advanced 演示 SystemOneAs[T] 自定义业务模型直解、Models.List 模型查询、请求级局部配置覆盖、WithExtraBody、强类型错误捕获以及凭证自动脱敏日志记录。

本地运行示例

克隆仓库并设置你的 API Key:

git clone https://github.com/guchengod/typesafe-sdk-go.git
cd typesafe-sdk-go

export TYPESAFE_API_KEY="ts_live_..."

# 运行快速入门示例
go run ./examples/quickstart

# 运行高级特性示例
go run ./examples/advanced

quickstart 示例的标准控制台输出如下:

model: jev-1.13.0
tokens: 492 in / 72 out
request id: req_01a0b7...
noul   is_billing p(true)=0.9900
choice category   billing (confidence 1.00, p=map[billing:1 other:0 technical:0])
score  urgency    1.90/2.0 (confidence 0.85)

Clone this wiki locally