Skip to content

docs: add Hy3 API quickstart guide and 6 standalone examples (#rhinobird2026) - #203

Open
wonder37-debug wants to merge 2 commits into
Tencent-Hunyuan:rhinobird2026from
wonder37-debug:docs/quickstart-examples
Open

docs: add Hy3 API quickstart guide and 6 standalone examples (#rhinobird2026)#203
wonder37-debug wants to merge 2 commits into
Tencent-Hunyuan:rhinobird2026from
wonder37-debug:docs/quickstart-examples

Conversation

@wonder37-debug

Copy link
Copy Markdown

Description

新增 Hy3 API Quickstart 双语文档及 6 个独立可运行的 Python 示例代码(针对 #rhinobird2026 分支)。

主要变更

  • Quickstart 文档
    • quickstart.md / quickstart_CN.md:中英双语指南,包含基础配置、参数说明、思考模式配置及常见报错排查。
  • 示例代码 (examples/)
    • basic_chat.py:单轮与多轮对话管理。
    • streaming.py:流式响应逐 Chunk 实时解析。
    • latency_compare.py:非流式与流式耗时对比(含 TTFT 首 Token 时延分析)。
    • tool_calling.py:Function Calling 定义与多轮工具循环处理。
    • reasoning_mode.py:思考模式开关(reasoning_effort)与思维链(reasoning_content)解析。
    • error_handling_retry.py:针对 429 限流、超时和网络错误的指数退避重试。

Copilot AI review requested due to automatic review settings July 31, 2026 12:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds bilingual Hy3 OpenAI-compatible API quickstart documentation plus 6 runnable Python examples to help users validate local deployments (vLLM/SGLang) and learn common patterns (streaming, tool calling, retries, reasoning mode).

Changes:

  • Added English/Chinese Quickstart guides covering endpoint basics, parameters, and troubleshooting.
  • Added 6 standalone openai-SDK Python scripts demonstrating chat, streaming, latency measurement, tool-calling loops, reasoning mode, and retry/backoff handling.
  • Included minimal vLLM deployment snippet for local serving.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
quickstart.md English Hy3 API quickstart guide and troubleshooting.
quickstart_CN.md Chinese Hy3 API quickstart guide and troubleshooting.
examples/basic_chat.py Basic single-turn and multi-turn chat usage.
examples/streaming.py Streaming chunk parsing example.
examples/latency_compare.py Streaming vs non-streaming latency comparison script.
examples/tool_calling.py Tool/function calling definition and multi-turn tool loop.
examples/reasoning_mode.py Reasoning mode (reasoning_effort) usage and output parsing.
examples/error_handling_retry.py Retry/backoff example for 429/timeout/network failures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +58 to +62
total += delta.content
elapsed = time.perf_counter() - t0
print(f"[streaming] first_token={ttft:.3f}s, total={elapsed:.3f}s, "
f"chars={len(total)}")
return ttft, elapsed
Comment thread examples/tool_calling.py Outdated
return msg.content

# echo the assistant message (must keep tool_calls) then run each tool
messages.append(msg) # OpenAI SDK message object is JSON-serializable
Comment thread examples/error_handling_retry.py Outdated
Comment on lines +49 to +51
ra = resp.headers.get("Retry-After")
if ra and ra.isdigit():
retry_after = float(ra)
Comment thread examples/basic_chat.py Outdated
Comment on lines +42 to +47
usage = response.usage # prompt_tokens / completion_tokens / total_tokens

print("=== Single-turn ===")
print(answer)
print(f"[finish_reason={finish_reason}] "
f"[usage: prompt={usage.prompt_tokens}, completion={usage.completion_tokens}]")
Comment thread quickstart.md Outdated
Comment on lines +67 to +69
| `reasoning_effort` | string | `high` | Thinking-mode switch: `no_think` (fast), `low`, `high` (deep chain-of-thought) |

Thinking mode: `reasoning_effort` accepts `no_think`, `low`, or `high`. The model defaults to slow thinking (`high`); set it to `no_think` explicitly for direct responses. The parameter is passed via `chat_template_kwargs` (use `extra_body` with the Python SDK). When enabled, the chain-of-thought is returned in the `reasoning_content` field.
Comment thread quickstart_CN.md Outdated
Comment on lines +67 to +69
| `reasoning_effort` | string | `high` | 思考模式开关:`no_think`(快思考)、`low`、`high`(深度思维链) |

思考模式:`reasoning_effort` 可选 `no_think`、`low`、`high`。模型默认以慢思考(`high`)输出;如需直接回复,请显式设为 `no_think`。该参数通过 `chat_template_kwargs` 透传(Python SDK 使用 `extra_body`)。开启后思维链内容以 `reasoning_content` 字段返回。
Comment thread examples/reasoning_mode.py Outdated
Comment on lines +9 to +10
The model defaults to slow thinking (high). When thinking is enabled, the
chain-of-thought is returned in `reasoning_content` (separate from `content`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants