From a4beb53dc6659b3e428400423f7a4a2c1ea132dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Fri, 18 Sep 2026 18:51:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84Tripo=E5=86=92=E7=83=9FCLI?= =?UTF-8?q?=E4=BA=A7=E7=89=A9=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 等待三类生成任务完成并打印映射后的输出 完成后下载模型产物到当前目录并输出文件信息 仅在示例内部使用SDK轮询器,不扩展平台公共接口 --- .../examples/tripo_generation_smoke.rs | 41 ++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/server-rs/crates/platform-tripo/examples/tripo_generation_smoke.rs b/server-rs/crates/platform-tripo/examples/tripo_generation_smoke.rs index 672eef477..79a102bf9 100644 --- a/server-rs/crates/platform-tripo/examples/tripo_generation_smoke.rs +++ b/server-rs/crates/platform-tripo/examples/tripo_generation_smoke.rs @@ -8,10 +8,11 @@ //! --manifest-path server-rs/Cargo.toml //! ``` //! -//! The example performs one-shot task queries after submission. It does not -//! expose or call the SDK's polling helpers. +//! The example waits for each submitted task to finish, prints its mapped +//! output, and writes the downloaded model into the current directory. The +//! SDK poller is used only here and is not exposed by `platform-tripo`. -use std::{env, time::Duration}; +use std::{env, fs, time::Duration}; use platform_tripo::TripoProviderClient; use shared_contracts::model3d::{ @@ -20,6 +21,7 @@ use shared_contracts::model3d::{ multiview_to_model::{Model3dMultiviewInputs, Model3dMultiviewToModelRequest}, text_to_model::Model3dTextToModelRequest, }; +use tripo3d_sdk::{ClientOptions, TripoClient, WaitOptions}; const SAMPLE_IMAGE_URL: &str = "https://raw.githubusercontent.com/VAST-AI-Research/tripo-python-sdk/master/example.png"; @@ -28,6 +30,13 @@ const SAMPLE_IMAGE_URL: &str = async fn main() -> Result<(), Box> { let api_key = required_env("TRIPO_API_KEY")?; let base_url = required_env("TRIPO_BASE_URL")?; + let sdk_client = TripoClient::new(ClientOptions { + api_key: Some(api_key.clone()), + base_url: Some(base_url.clone()), + timeout: Some(Duration::from_secs(60)), + retries: Some(2), + user_agent: Some("genarrative-tripo-smoke/1".to_string()), + })?; let client = TripoProviderClient::new(platform_tripo::TripoSettings::new( api_key, base_url, @@ -125,10 +134,32 @@ async fn main() -> Result<(), Box> { ("image_to_model", image), ("multiview_to_model", multiview), ] { + // The SDK poller is used only by this smoke example. It is not part + // of the platform-tripo public API. + sdk_client + .wait_for_task( + &handle.task_id, + WaitOptions { + timeout: Some(Duration::from_secs(30 * 60)), + ..WaitOptions::default() + }, + ) + .await?; + let snapshot = client.get_task(&handle).await?; println!( - "{name} status={:?} progress={:?}", - snapshot.status, snapshot.progress + "{name} status={:?} progress={:?} output={:?}", + snapshot.status, snapshot.progress, snapshot.output + ); + + let downloaded = client.download_model(&snapshot).await?; + let filename = downloaded.filename(name); + fs::write(&filename, &downloaded.data)?; + println!( + "{name} artifact={} bytes={} url={}", + filename, + downloaded.data.len(), + downloaded.url ); }