fix: update website SDK examples to use init() API#1243
Conversation
- Replace III()/III::new() + connect() with init() across all website code examples
- Update Python imports from `from iii import III` to `from iii import init`
- Update Rust imports from `use iii_sdk::III` to `use iii_sdk::{init, InitOptions}`
- Update Rust trigger API to match current SDK surface
- Add init() to DependencyVisualization architecture line detection
📝 WalkthroughWalkthroughDocumentation and embedded code samples were updated to use the new init-based SDK initialization pattern and to rename function/trigger identifiers from colon-separated (e.g., "users::create") to dot-separated form (e.g., "users.create"); HTTP trigger paths were normalized to include a leading slash (e.g., "/users"). Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
website/components/MachineView.tsx (1)
78-91:⚠️ Potential issue | 🟡 MinorInconsistent function ID format and API path between TypeScript and Python/Rust examples.
The Python and Rust sections were updated to use
users.create(dot separator) and"/users"(leading slash), but the TypeScript section still usesusers::create(double-colon) and"users"(no slash). This creates inconsistency in the SDK documentation.Suggested fix to align TypeScript with Python/Rust
iii.registerFunction( - { id: "users::create" }, + { id: "users.create" }, async (input) => { const { logger } = getContext() logger.info("Creating user", { email: input.email }) return { id: "123", email: input.email } } ) iii.registerTrigger({ type: "http", - function_id: "users::create", - config: { api_path: "users", http_method: "POST" } + function_id: "users.create", + config: { api_path: "/users", http_method: "POST" } })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@website/components/MachineView.tsx` around lines 78 - 91, The TypeScript example uses an inconsistent function id and API path; update iii.registerFunction to use id: "users.create" (dot separator) and update the trigger config to use config.api_path: "/users" (leading slash) and ensure function_id in iii.registerTrigger matches "users.create" so the TypeScript snippet aligns with the Python/Rust examples; locate the usage via iii.registerFunction and iii.registerTrigger and adjust the id, function_id, and config.api_path values accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@website/components/sections/AgentReadySection.tsx`:
- Around line 90-98: The function ID used across language examples must be
consistent; update the TypeScript example that currently uses "agent::research"
to use "agent.research" so it matches the Python
(iii.register_function("agent.research", research_handler)) and Rust
(RegisterFunctionInput { id: "agent.research" ... }) examples; locate the
TypeScript tab containing the string "agent::research" and replace it with
"agent.research" to ensure all three tabs show the same function ID.
- Around line 292-293: The TypeScript sample's subscription name must match the
renamed Python worker; update the TS polyglot flow to use the dot-form function
IDs (e.g., "ml.onboarding" and "ml.recommend") to match the Python registrations
(iii.register_function("ml.onboarding", predict_handler) and
iii.register_function("ml.recommend", recommend_handler)), or alternatively
rename the Python registrations back to the double-colon form ("ml::onboarding",
"ml::recommend") so both sides use the same identifier; locate the TS
subscription code for the onboarding/recommend capability and make the
identifier consistent with the Python side.
- Around line 74-76: Add "import os" to the Python code examples that reference
os.environ.get so they don't raise NameError when copied; locate the snippets
using the symbols shown (python: `from iii import init, get_context` and `iii =
init(os.environ.get("III_BRIDGE_URL", "ws://localhost:49134"))`) in
AgentReadySection.tsx and prepend or include `import os` in those blocks so os
is defined.
In `@website/components/sections/HelloWorldSection.tsx`:
- Line 38: The registered worker names were changed to dot notation
("ml.predict" and "data.transform") but the trigger calls still use the old
double-colon form ("ml::predict" and "data::transform"); update the
trigger/invocation strings to match the registered names so all snippets use
"ml.predict" and "data.transform" consistently (search for occurrences of
"ml::predict" and "data::transform" and replace them with "ml.predict" and
"data.transform", ensuring the registered functions like predict and transform
remain referenced correctly).
In `@website/components/Terminal.tsx`:
- Around line 311-312: The Rust snippet logged in Terminal.tsx calls init and
InitOptions but omits the required import; update the snippet where
addLog("Rust:", "warning") and addLog('let iii = init("ws://127.0.0.1:49134",
InitOptions::default())?;', "success") are added to include the proper import
(matching other examples that import from iii_sdk) so the snippet is
copy-pasteable—add the appropriate use/import line for init and InitOptions
before the init call.
---
Outside diff comments:
In `@website/components/MachineView.tsx`:
- Around line 78-91: The TypeScript example uses an inconsistent function id and
API path; update iii.registerFunction to use id: "users.create" (dot separator)
and update the trigger config to use config.api_path: "/users" (leading slash)
and ensure function_id in iii.registerTrigger matches "users.create" so the
TypeScript snippet aligns with the Python/Rust examples; locate the usage via
iii.registerFunction and iii.registerTrigger and adjust the id, function_id, and
config.api_path values accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 993d15b3-914c-4264-a145-b1a975237e47
📒 Files selected for processing (6)
website/components/MachineView.tsxwebsite/components/Terminal.tsxwebsite/components/sections/AgentReadySection.tsxwebsite/components/sections/DependencyVisualization.tsxwebsite/components/sections/EngineSection.tsxwebsite/components/sections/HelloWorldSection.tsx
| python: `from iii import init, get_context | ||
|
|
||
| iii = III(os.environ.get("III_BRIDGE_URL", "ws://localhost:49134")) | ||
| await iii.connect() | ||
| iii = init(os.environ.get("III_BRIDGE_URL", "ws://localhost:49134")) |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check if the file exists and get its line count
wc -l website/components/sections/AgentReadySection.tsxRepository: MotiaDev/motia
Length of output: 112
🏁 Script executed:
#!/bin/bash
# Run the verification script provided in the review
python - <<'PY'
from pathlib import Path
text = Path("website/components/sections/AgentReadySection.tsx").read_text()
for idx, block in enumerate(text.split('python: `')[1:], 1):
snippet = block.split('`', 1)[0]
if 'os.environ.get("III_BRIDGE_URL"' in snippet:
print(f"python snippet {idx}: import os present ->", 'import os' in snippet)
PYRepository: MotiaDev/motia
Length of output: 147
🏁 Script executed:
#!/bin/bash
# Read lines 70-80 to see context around line 74-76
sed -n '70,80p' website/components/sections/AgentReadySection.tsxRepository: MotiaDev/motia
Length of output: 319
🏁 Script executed:
#!/bin/bash
# Read lines 273-283 to see context around line 277-279
sed -n '273,283p' website/components/sections/AgentReadySection.tsxRepository: MotiaDev/motia
Length of output: 380
Add import os to the updated Python snippets.
Both snippets at lines 74-76 and 277-279 call os.environ.get("III_BRIDGE_URL", ...) without importing os, causing a NameError when copied and executed.
Proposed fix
- python: `from iii import init, get_context
+ python: `import os
+from iii import init, get_context📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| python: `from iii import init, get_context | |
| iii = III(os.environ.get("III_BRIDGE_URL", "ws://localhost:49134")) | |
| await iii.connect() | |
| iii = init(os.environ.get("III_BRIDGE_URL", "ws://localhost:49134")) | |
| python: `import os | |
| from iii import init, get_context | |
| iii = init(os.environ.get("III_BRIDGE_URL", "ws://localhost:49134")) |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@website/components/sections/AgentReadySection.tsx` around lines 74 - 76, Add
"import os" to the Python code examples that reference os.environ.get so they
don't raise NameError when copied; locate the snippets using the symbols shown
(python: `from iii import init, get_context` and `iii =
init(os.environ.get("III_BRIDGE_URL", "ws://localhost:49134"))`) in
AgentReadySection.tsx and prepend or include `import os` in those blocks so os
is defined.
| addLog("Rust:", "warning"); | ||
| addLog('let iii = III::new("ws://127.0.0.1:49134");', "success"); | ||
| addLog("iii.connect().await?;", "success"); | ||
| addLog('let iii = init("ws://127.0.0.1:49134", InitOptions::default())?;', "success"); |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, let's read the relevant section of Terminal.tsx around lines 311-312
sed -n '305,320p' website/components/Terminal.tsxRepository: MotiaDev/motia
Length of output: 712
🏁 Script executed:
# Also check the Python snippet mentioned around lines 308-309 for context
sed -n '300,330p' website/components/Terminal.tsxRepository: MotiaDev/motia
Length of output: 1399
🏁 Script executed:
# Search for other Rust import examples in this file to see the pattern
rg -A 2 "use iii_sdk" website/components/Terminal.tsxRepository: MotiaDev/motia
Length of output: 40
🏁 Script executed:
# Search for iii_sdk references in the entire codebase to understand the library structure
rg "iii_sdk" --type rust --type ts --type jsRepository: MotiaDev/motia
Length of output: 8836
🏁 Script executed:
# Check if there's documentation or examples of iii_sdk usage
fd -e md -e txt -e rs | head -20 | xargs grep -l "iii_sdk" 2>/dev/null || echo "No matches in docs"Repository: MotiaDev/motia
Length of output: 292
🏁 Script executed:
# Look for package.json or Cargo.toml to understand project dependencies
fd -e "Cargo.toml|package.json" | head -5 | xargs catRepository: MotiaDev/motia
Length of output: 40
🌐 Web query:
iii_sdk Rust crate init InitOptions
💡 Result:
The iii-sdk Rust crate (iii_sdk) does not have an init module with an InitOptions type in the current upstream repo/docs. The primary “init” pattern is:
- Create the client with
III::new(ws_url)and theniii.connect().await?before registering/calling functions. [1] - If you meant OpenTelemetry initialization, the crate exposes
telemetry::init_otel(config: OtelConfig)(called once at startup; subsequent calls are no-ops).OtelConfigis the options/config struct you customize (service name, engine WS URL, metrics/logs toggles, reconnection config, etc.). [2][3]
Sources: [1][2][3]
Add the missing Rust import to keep this snippet copy-pasteable.
The Rust snippet uses init and InitOptions without importing them, making the code non-functional. The Python example above includes from iii import init, and other examples throughout the codebase (AgentReadySection.tsx, HelloWorldSection.tsx, MachineView.tsx) consistently import from iii_sdk. This snippet needs the same treatment.
Suggested fix
addLog("Rust:", "warning");
+ addLog("use iii_sdk::{init, InitOptions};", "success");
addLog('let iii = init("ws://127.0.0.1:49134", InitOptions::default())?;', "success");📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| addLog("Rust:", "warning"); | |
| addLog('let iii = III::new("ws://127.0.0.1:49134");', "success"); | |
| addLog("iii.connect().await?;", "success"); | |
| addLog('let iii = init("ws://127.0.0.1:49134", InitOptions::default())?;', "success"); | |
| addLog("Rust:", "warning"); | |
| addLog("use iii_sdk::{init, InitOptions};", "success"); | |
| addLog('let iii = init("ws://127.0.0.1:49134", InitOptions::default())?;', "success"); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@website/components/Terminal.tsx` around lines 311 - 312, The Rust snippet
logged in Terminal.tsx calls init and InitOptions but omits the required import;
update the snippet where addLog("Rust:", "warning") and addLog('let iii =
init("ws://127.0.0.1:49134", InitOptions::default())?;', "success") are added to
include the proper import (matching other examples that import from iii_sdk) so
the snippet is copy-pasteable—add the appropriate use/import line for init and
InitOptions before the init call.
- Update TS function IDs from :: to . notation to match Python/Rust - Add leading / to api_path in TS trigger configs - Fixes cross-tab inconsistencies in AgentReadySection, HelloWorldSection, MachineView
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
website/components/sections/AgentReadySection.tsx (1)
58-69:⚠️ Potential issue | 🟠 MajorChange
responsefromconsttoletto allow reassignment in the loop.Line 61 declares
responseasconst, but line 69 reassigns it. This is a TypeScript error—const variables cannot be reassigned.Suggested fix
- const response = await callLLM(query, { tools }) + let response = await callLLM(query, { tools })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@website/components/sections/AgentReadySection.tsx` around lines 58 - 69, The variable response inside the iii.registerFunction handler is declared as const but later reassigned in the while loop; change its declaration to let so it can be updated. Locate the handler registered by iii.registerFunction (id "agent.research") where response is assigned from callLLM(query, { tools }) and update that declaration to let; keep the rest of the logic (the while (response.toolCall) loop, calls to iii.trigger and subsequent callLLM) unchanged.
♻️ Duplicate comments (1)
website/components/sections/AgentReadySection.tsx (1)
74-76:⚠️ Potential issue | 🟠 MajorImport
osbefore usingos.environin both Python snippets.Lines 76 and 279 call
os.environ.get(...), but neither snippet importsos, so both examples fail immediately withNameError.Suggested fix
- python: `from iii import init, get_context + python: `import os +from iii import init, get_context ... - python: `from iii import init, get_context + python: `import os +from iii import init, get_contextAlso applies to: 277-279
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@website/components/sections/AgentReadySection.tsx` around lines 74 - 76, The Python examples that call os.environ.get(...) are missing the os import and will raise NameError; update both inline snippets in AgentReadySection.tsx (the snippet starting with "python: `from iii import init, get_context" and the later snippet around the second os.environ.get usage) to include an import os line (i.e., add "import os" before using os.environ.get) so the examples run correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@website/components/sections/AgentReadySection.tsx`:
- Around line 91-98: The Rust example fails to compile because
RegisterFunctionInput is used but not imported; update the import at the top of
the snippet (the use iii_sdk::{init, InitOptions, get_context}; line) to also
include RegisterFunctionInput so that the subsequent call to
iii.register_function(RegisterFunctionInput { ... }) is valid and the example
compiles.
---
Outside diff comments:
In `@website/components/sections/AgentReadySection.tsx`:
- Around line 58-69: The variable response inside the iii.registerFunction
handler is declared as const but later reassigned in the while loop; change its
declaration to let so it can be updated. Locate the handler registered by
iii.registerFunction (id "agent.research") where response is assigned from
callLLM(query, { tools }) and update that declaration to let; keep the rest of
the logic (the while (response.toolCall) loop, calls to iii.trigger and
subsequent callLLM) unchanged.
---
Duplicate comments:
In `@website/components/sections/AgentReadySection.tsx`:
- Around line 74-76: The Python examples that call os.environ.get(...) are
missing the os import and will raise NameError; update both inline snippets in
AgentReadySection.tsx (the snippet starting with "python: `from iii import init,
get_context" and the later snippet around the second os.environ.get usage) to
include an import os line (i.e., add "import os" before using os.environ.get) so
the examples run correctly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a7acb935-4b42-47e6-9c62-0c8b62033fa2
📒 Files selected for processing (3)
website/components/MachineView.tsxwebsite/components/sections/AgentReadySection.tsxwebsite/components/sections/HelloWorldSection.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- website/components/MachineView.tsx
| rust: `use iii_sdk::{init, InitOptions, get_context}; | ||
|
|
||
| let iii = III::new("ws://localhost:49134"); | ||
| iii.connect().await?; | ||
| let iii = init("ws://localhost:49134", InitOptions::default())?; | ||
| let logger = get_context().logger; | ||
| let tools = iii.list_functions().await?; | ||
|
|
||
| iii.register_function( | ||
| RegisterFunctionInput { id: "agent::research".into(), ..Default::default() }, | ||
| RegisterFunctionInput { id: "agent.research".into(), ..Default::default() }, |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cat -n website/components/sections/AgentReadySection.tsx | sed -n '85,105p'Repository: MotiaDev/motia
Length of output: 1160
Add RegisterFunctionInput to the Rust example's import statement.
Line 98 uses RegisterFunctionInput, but line 91 does not import it. As written, the sample code does not compile.
Suggested fix
- rust: `use iii_sdk::{init, InitOptions, get_context};
+ rust: `use iii_sdk::{get_context, init, InitOptions, RegisterFunctionInput};🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@website/components/sections/AgentReadySection.tsx` around lines 91 - 98, The
Rust example fails to compile because RegisterFunctionInput is used but not
imported; update the import at the top of the snippet (the use iii_sdk::{init,
InitOptions, get_context}; line) to also include RegisterFunctionInput so that
the subsequent call to iii.register_function(RegisterFunctionInput { ... }) is
valid and the example compiles.
Summary
III()/III::new()+connect()withinit()across all website code examples to match the new SDK API from c1bb119from iii import III→from iii import inituse iii_sdk::III→use iii_sdk::{init, InitOptions}init(to DependencyVisualization architecture line detectionFiles changed
website/components/Terminal.tsx— Python/Rust SDK exampleswebsite/components/MachineView.tsx— Python/Rust SDK code blockswebsite/components/sections/AgentReadySection.tsx— All Python/Rust examples (4 blocks)website/components/sections/HelloWorldSection.tsx— Python/Rust code snippetswebsite/components/sections/EngineSection.tsx— Discovery code snippetswebsite/components/sections/DependencyVisualization.tsx— Code highlighting logicTest plan
III()/III::new()/iii.connect()patterns in websiteSummary by CodeRabbit