-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat(i18n): update translations #1572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Summary
This PR contains automated translations for the Python and TypeScript SDK documentation across five languages (Spanish, French, Chinese, Japanese, and German). The changes were triggered by upstream modifications to the English documentation, specifically adding chat streaming functionality to the SDK docs. The translation system used Lingo.dev AI translation engine to generate multilingual versions of the updated content.While the Python SDK translations show only minor whitespace cleanup changes, the TypeScript SDK translations have significant issues that need immediate attention. The automated translation process has introduced critical formatting errors in the TypeScript documentation, including malformed markdown code blocks where the language identifier is separated from the opening backticks by line breaks, extensive content duplication where entire sections appear multiple times, and incomplete translations mixing languages inconsistently.
The translation workflow integrates with the existing documentation structure in apps/docs/content/docs/ where each language has its own subdirectory (en/, es/, fr/, zh/, ja/, de/) containing the same file structure as the English version. This maintains consistency with the project's internationalization approach.
Important Files Changed
Changed Files
| Filename | Score | Overview |
|---|---|---|
| apps/docs/content/docs/zh/sdks/python.mdx | 5/5 | Chinese Python SDK translation with minor whitespace cleanup |
| apps/docs/content/docs/es/sdks/python.mdx | 5/5 | Spanish Python SDK translation with trailing whitespace removal |
| apps/docs/content/docs/fr/sdks/python.mdx | 4/5 | French Python SDK translation with inconsistent whitespace formatting |
| apps/docs/content/docs/ja/sdks/python.mdx | 5/5 | Japanese Python SDK translation with minor whitespace adjustments |
| apps/docs/content/docs/de/sdks/python.mdx | 5/5 | German Python SDK translation with whitespace cleanup |
| apps/docs/content/docs/zh/sdks/typescript.mdx | 2/5 | Chinese TypeScript SDK translation with duplicated content and malformed code blocks |
| apps/docs/content/docs/de/sdks/typescript.mdx | 1/5 | German TypeScript SDK translation with broken markdown and massive duplication |
| apps/docs/content/docs/fr/sdks/typescript.mdx | 1/5 | French TypeScript SDK translation with critical formatting issues and content duplication |
| apps/docs/content/docs/ja/sdks/typescript.mdx | 1/5 | Japanese TypeScript SDK translation with malformed code blocks and duplicated sections |
| apps/docs/content/docs/es/sdks/typescript.mdx | 1/5 | Spanish TypeScript SDK translation with broken formatting and incomplete translations |
Confidence score: 2/5
- This PR has critical issues that will break documentation rendering and must be fixed before merging
- Score reflects serious formatting problems in TypeScript translations that would prevent proper markdown rendering and create poor user experience
- Pay immediate attention to all TypeScript SDK translation files which have broken code block formatting and extensive content duplication
Additional Comments (5)
-
apps/docs/content/docs/ja/sdks/typescript.mdx, line 820-1292 (link)logic: Entire section duplicated - content from line 820 onward repeats the streaming workflow documentation
-
apps/docs/content/docs/ja/sdks/typescript.mdx, line 818 (link)syntax: Incomplete sentence 'Current period cost: ' needs completion or removal
-
apps/docs/content/docs/es/sdks/typescript.mdx, line 824-848 (link)syntax: Code block formatting is broken - missing proper typescript syntax highlighting and has incorrect line breaks. Should be:
typescript
import { SimStudioClient } from 'simstudio-ts-sdk';const client = new SimStudioClient({
apiKey: process.env.SIM_API_KEY!
});
4. `apps/docs/content/docs/es/sdks/typescript.mdx`, line 866-936 ([link](/simstudioai/sim/blob/b12204eccd0ebecdc665a65ef3f9c0c19afd7cbd/apps/docs/content/docs/es/sdks/typescript.mdx#L866-L936))
**syntax:** Another malformed code block with incorrect backticks and formatting. The typescript code block syntax is broken.
typescript
import { useState, useEffect } from 'react';
function StreamingWorkflow() {
const [output, setOutput] = useState('');
const [loading, setLoading] = useState(false);
const executeStreaming = async () => {
setLoading(true);
setOutput('');
// IMPORTANT: Make this API call from your backend server, not the browser
// Never expose your API key in client-side code
const response = await fetch('https://sim.ai/api/workflows/WORKFLOW_ID/execute', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': process.env.SIM_API_KEY! // Server-side environment variable only
},
body: JSON.stringify({
message: 'Generate a story',
stream: true,
selectedOutputs: ['agent1.content']
})
});
const reader = response.body?.getReader();
const decoder = new TextDecoder();
while (reader) {
const { done, value } = await reader.read();
if (done) break;
const chunk = decoder.decode(value);
const lines = chunk.split('\n\n');
for (const line of lines) {
if (line.startsWith('data: ')) {
const data = line.slice(6);
if (data === '[DONE]') {
setLoading(false);
break;
}
try {
const parsed = JSON.parse(data);
if (parsed.chunk) {
setOutput(prev => prev + parsed.chunk);
} else if (parsed.event === 'done') {
console.log('Execution complete:', parsed.metadata);
}
} catch (e) {
// Skip invalid JSON
}
}
}
}
};
return (
<div>
<button onClick={executeStreaming} disabled={loading}>
{loading ? 'Generando...' : 'Iniciar streaming'}
</button>
<div style={{ whiteSpace: 'pre-wrap' }}>{output}</div>
</div>
);
}
-
apps/docs/content/docs/es/sdks/typescript.mdx, line 818 (link)syntax: Incomplete line - the text cuts off mid-sentence with 'Current period cost:' and no completion.
10 files reviewed, 23 comments
| import os | ||
|
|
||
| client = SimStudioClient(api_key=os.getenv("SIM_API_KEY")) | ||
| client = SimStudioClient(api_key=os.getenv("SIM_API_KEY")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Inconsistent trailing whitespace - this line has extra spaces while similar lines (390, 612) were cleaned up
| client = SimStudioClient(api_key=os.getenv("SIM_API_KEY")) | |
| client = SimStudioClient(api_key=os.getenv("SIM_API_KEY")) |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/docs/content/docs/fr/sdks/python.mdx
Line: 436:436
Comment:
**style:** Inconsistent trailing whitespace - this line has extra spaces while similar lines (390, 612) were cleaned up
```suggestion
client = SimStudioClient(api_key=os.getenv("SIM_API_KEY"))
```
How can I resolve this? If you propose a fix, please make it concise.| ``` | ||
| typescript |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: Same malformed code block syntax issue
| ``` | |
| typescript | |
| ```typescript |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/docs/content/docs/zh/sdks/typescript.mdx
Line: 866:868
Comment:
**syntax:** Same malformed code block syntax issue
```suggestion
```typescript
```
How can I resolve this? If you propose a fix, please make it concise.| ``` | ||
|
|
||
| ## Getting Your API Key | ||
|
|
||
| <Steps> | ||
| <Step title="Log in to Sim"> | ||
| Navigate to [Sim](https://sim.ai) and log in to your account. | ||
| </Step> | ||
| <Step title="Open your workflow"> | ||
| Navigate to the workflow you want to execute programmatically. | ||
| </Step> | ||
| <Step title="Deploy your workflow"> | ||
| Click on "Deploy" to deploy your workflow if it hasn't been deployed yet. | ||
| </Step> | ||
| <Step title="Create or select an API key"> | ||
| During the deployment process, select or create an API key. | ||
| </Step> | ||
| <Step title="Copy the API key"> | ||
| Copy the API key to use in your TypeScript/JavaScript application. | ||
| </Step> | ||
| </Steps> | ||
|
|
||
| <Callout type="warning"> | ||
| Keep your API key secure and never commit it to version control. Use environment variables or secure configuration management. | ||
| </Callout> | ||
|
|
||
| ## Requirements | ||
|
|
||
| - Node.js 16+ | ||
| - TypeScript 5.0+ (for TypeScript projects) | ||
|
|
||
| ## TypeScript Support | ||
|
|
||
| The SDK is written in TypeScript and provides full type safety: | ||
|
|
||
| ``` | ||
| typescript | ||
| import { | ||
| SimStudioClient, | ||
| WorkflowExecutionResult, | ||
| WorkflowStatus, | ||
| SimStudioError | ||
| } from 'simstudio-ts-sdk'; | ||
| // 类型安全的客户端初始化 | ||
| const client: SimStudioClient = new SimStudioClient({ | ||
| apiKey: process.env.SIM_API_KEY! | ||
| }); | ||
| // 类型安全的工作流执行 | ||
| const result: WorkflowExecutionResult = await client.executeWorkflow('workflow-id', { | ||
| input: { | ||
| message: '你好,TypeScript!' | ||
| } | ||
| }); | ||
| // 类型安全的状态检查 | ||
| const status: WorkflowStatus = await client.getWorkflowStatus('workflow-id'); | ||
| ``` | ||
|
|
||
| ## 许可证 | ||
|
|
||
| Apache-2.0 | ||
|
|
||
| const reader = response.body?.getReader(); | ||
| const decoder = new TextDecoder(); | ||
|
|
||
| while (reader) { | ||
| const { done, value } = await reader.read(); | ||
| if (done) break; | ||
|
|
||
| const chunk = decoder.decode(value); | ||
| const lines = chunk.split('\n\n'); | ||
|
|
||
| for (const line of lines) { | ||
| if (line.startsWith('data: ')) { | ||
| const data = line.slice(6); | ||
| if (data === '[DONE]') { | ||
| setLoading(false); | ||
| break; | ||
| } | ||
|
|
||
| try { | ||
| const parsed = JSON.parse(data); | ||
| if (parsed.chunk) { | ||
| setOutput(prev => prev + parsed.chunk); | ||
| } else if (parsed.event === 'done') { | ||
| console.log('执行完成:', parsed.metadata); | ||
| } | ||
| } catch (e) { | ||
| // 跳过无效的 JSON | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <div> | ||
| <button onClick={executeStreaming} disabled={loading}> | ||
| {loading ? '生成中...' : '开始流式传输'} | ||
| </button> | ||
| <div style={{ whiteSpace: 'pre-wrap' }}>{output}</div> | ||
| </div> | ||
| ); | ||
| } | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Entire duplicated section with React streaming example that appears earlier in the file
| ``` | |
| ## Getting Your API Key | |
| <Steps> | |
| <Step title="Log in to Sim"> | |
| Navigate to [Sim](https://sim.ai) and log in to your account. | |
| </Step> | |
| <Step title="Open your workflow"> | |
| Navigate to the workflow you want to execute programmatically. | |
| </Step> | |
| <Step title="Deploy your workflow"> | |
| Click on "Deploy" to deploy your workflow if it hasn't been deployed yet. | |
| </Step> | |
| <Step title="Create or select an API key"> | |
| During the deployment process, select or create an API key. | |
| </Step> | |
| <Step title="Copy the API key"> | |
| Copy the API key to use in your TypeScript/JavaScript application. | |
| </Step> | |
| </Steps> | |
| <Callout type="warning"> | |
| Keep your API key secure and never commit it to version control. Use environment variables or secure configuration management. | |
| </Callout> | |
| ## Requirements | |
| - Node.js 16+ | |
| - TypeScript 5.0+ (for TypeScript projects) | |
| ## TypeScript Support | |
| The SDK is written in TypeScript and provides full type safety: | |
| ``` | |
| typescript | |
| import { | |
| SimStudioClient, | |
| WorkflowExecutionResult, | |
| WorkflowStatus, | |
| SimStudioError | |
| } from 'simstudio-ts-sdk'; | |
| // 类型安全的客户端初始化 | |
| const client: SimStudioClient = new SimStudioClient({ | |
| apiKey: process.env.SIM_API_KEY! | |
| }); | |
| // 类型安全的工作流执行 | |
| const result: WorkflowExecutionResult = await client.executeWorkflow('workflow-id', { | |
| input: { | |
| message: '你好,TypeScript!' | |
| } | |
| }); | |
| // 类型安全的状态检查 | |
| const status: WorkflowStatus = await client.getWorkflowStatus('workflow-id'); | |
| ``` | |
| ## 许可证 | |
| Apache-2.0 | |
| const reader = response.body?.getReader(); | |
| const decoder = new TextDecoder(); | |
| while (reader) { | |
| const { done, value } = await reader.read(); | |
| if (done) break; | |
| const chunk = decoder.decode(value); | |
| const lines = chunk.split('\n\n'); | |
| for (const line of lines) { | |
| if (line.startsWith('data: ')) { | |
| const data = line.slice(6); | |
| if (data === '[DONE]') { | |
| setLoading(false); | |
| break; | |
| } | |
| try { | |
| const parsed = JSON.parse(data); | |
| if (parsed.chunk) { | |
| setOutput(prev => prev + parsed.chunk); | |
| } else if (parsed.event === 'done') { | |
| console.log('执行完成:', parsed.metadata); | |
| } | |
| } catch (e) { | |
| // 跳过无效的 JSON | |
| } | |
| } | |
| } | |
| } | |
| }; | |
| return ( | |
| <div> | |
| <button onClick={executeStreaming} disabled={loading}> | |
| {loading ? '生成中...' : '开始流式传输'} | |
| </button> | |
| <div style={{ whiteSpace: 'pre-wrap' }}>{output}</div> | |
| </div> | |
| ); | |
| } | |
| ``` |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/docs/content/docs/zh/sdks/typescript.mdx
Line: 936:1044
Comment:
**logic:** Entire duplicated section with React streaming example that appears earlier in the file
```suggestion
```
How can I resolve this? If you propose a fix, please make it concise.| ``` | ||
| typescript | ||
| import { SimStudioClient } from 'simstudio-ts-sdk'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: Code block syntax is broken. The language identifier should be on the same line as the opening backticks.
| ``` | |
| typescript | |
| import { SimStudioClient } from 'simstudio-ts-sdk'; | |
| ```typescript | |
| import { SimStudioClient } from 'simstudio-ts-sdk'; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/docs/content/docs/de/sdks/typescript.mdx
Line: 824:827
Comment:
**syntax:** Code block syntax is broken. The language identifier should be on the same line as the opening backticks.
```suggestion
```typescript
import { SimStudioClient } from 'simstudio-ts-sdk';
```
How can I resolve this? If you propose a fix, please make it concise.| ``` | ||
| typescript | ||
| import { useState, useEffect } from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: Code block syntax is broken. Fix the markdown formatting.
| ``` | |
| typescript | |
| import { useState, useEffect } from 'react'; | |
| ```typescript | |
| import { useState, useEffect } from 'react'; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/docs/content/docs/de/sdks/typescript.mdx
Line: 866:869
Comment:
**syntax:** Code block syntax is broken. Fix the markdown formatting.
```suggestion
```typescript
import { useState, useEffect } from 'react';
```
How can I resolve this? If you propose a fix, please make it concise.| Apache-2.0 + limits.usage.limit.toFixed(2)); | ||
| console.log('Plan:', limits.usage.plan); | ||
| const percentUsed = (limits.usage.currentPeriodCost / limits.usage.limit) * 100; | ||
| console.log('Usage: ' + percentUsed.toFixed(1) + '%'); | ||
| if (percentUsed > 80) { | ||
| console.warn('⚠️ Warning: You are approaching your usage limit!'); | ||
| } | ||
| } catch (error) { | ||
| console.error('Error checking usage:', error); | ||
| } | ||
| } | ||
| checkUsage(); | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Duplicate code fragment that appears to be translation artifacts mixing with license text
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/docs/content/docs/fr/sdks/typescript.mdx
Line: 1105:1120
Comment:
**logic:** Duplicate code fragment that appears to be translation artifacts mixing with license text
How can I resolve this? If you propose a fix, please make it concise.| ``` | ||
| typescript |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: Code block is malformed - 'typescript' should be on the same line as opening backticks
| ``` | |
| typescript | |
| ```typescript |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/docs/content/docs/ja/sdks/typescript.mdx
Line: 824:826
Comment:
**syntax:** Code block is malformed - 'typescript' should be on the same line as opening backticks
```suggestion
```typescript
```
How can I resolve this? If you propose a fix, please make it concise.| ``` | ||
| data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":"One"} | ||
| data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":", two"} | ||
| data: {"event":"done","success":true,"output":{},"metadata":{"duration":610}} | ||
| data: [DONE] | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: Code block formatting is broken - the opening backticks and content should be properly formatted
| ``` | |
| data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":"One"} | |
| data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":", two"} | |
| data: {"event":"done","success":true,"output":{},"metadata":{"duration":610}} | |
| data: [DONE] | |
| ``` |
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":"One"}
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":", two"}
data: {"event":"done","success":true,"output":{},"metadata":{"duration":610}}
data: [DONE]
<details><summary>Prompt To Fix With AI</summary>
`````markdown
This is a comment left during a code review.
Path: apps/docs/content/docs/ja/sdks/typescript.mdx
Line: 852:862
Comment:
**syntax:** Code block formatting is broken - the opening backticks and content should be properly formatted
```suggestion
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":"One"}
data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":", two"}
data: {"event":"done","success":true,"output":{},"metadata":{"duration":610}}
data: [DONE]
How can I resolve this? If you propose a fix, please make it concise.
| ``` | ||
| typescript |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: Another malformed code block with 'typescript' separated from backticks
| ``` | |
| typescript | |
| ```typescript |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/docs/content/docs/ja/sdks/typescript.mdx
Line: 866:868
Comment:
**syntax:** Another malformed code block with 'typescript' separated from backticks
```suggestion
```typescript
```
How can I resolve this? If you propose a fix, please make it concise.| const reader = response.body?.getReader(); | ||
| const decoder = new TextDecoder(); | ||
|
|
||
| while (reader) { | ||
| const { done, value } = await reader.read(); | ||
| if (done) break; | ||
|
|
||
| const chunk = decoder.decode(value); | ||
| const lines = chunk.split('\n\n'); | ||
|
|
||
| for (const line of lines) { | ||
| if (line.startsWith('data: ')) { | ||
| const data = line.slice(6); | ||
| if (data === '[DONE]') { | ||
| setLoading(false); | ||
| break; | ||
| } | ||
|
|
||
| try { | ||
| const parsed = JSON.parse(data); | ||
| if (parsed.chunk) { | ||
| setOutput(prev => prev + parsed.chunk); | ||
| } else if (parsed.event === 'done') { | ||
| console.log('Ejecución completada:', parsed.metadata); | ||
| } | ||
| } catch (e) { | ||
| // Omitir JSON inválido | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <div> | ||
| <button onClick={executeStreaming} disabled={loading}> | ||
| {loading ? 'Generando...' : 'Iniciar streaming'} | ||
| </button> | ||
| <div style={{ whiteSpace: 'pre-wrap' }}>{output}</div> | ||
| </div> | ||
| ); | ||
| } | ||
| ``` | ||
| ## Getting Your API Key | ||
| <Steps> | ||
| <Step title="Log in to Sim"> | ||
| Navigate to [Sim](https://sim.ai) and log in to your account. | ||
| </Step> | ||
| <Step title="Open your workflow"> | ||
| Navigate to the workflow you want to execute programmatically. | ||
| </Step> | ||
| <Step title="Deploy your workflow"> | ||
| Click on "Deploy" to deploy your workflow if it hasn't been deployed yet. | ||
| </Step> | ||
| <Step title="Create or select an API key"> | ||
| During the deployment process, select or create an API key. | ||
| </Step> | ||
| <Step title="Copy the API key"> | ||
| Copy the API key to use in your TypeScript/JavaScript application. | ||
| </Step> | ||
| </Steps> | ||
| <Callout type="warning"> | ||
| Keep your API key secure and never commit it to version control. Use environment variables or secure configuration management. | ||
| </Callout> | ||
| ## Requirements | ||
| - Node.js 16+ | ||
| - TypeScript 5.0+ (for TypeScript projects) | ||
| ## TypeScript Support | ||
| The SDK is written in TypeScript and provides full type safety: | ||
| ```typescript | ||
| import { | ||
| SimStudioClient, | ||
| WorkflowExecutionResult, | ||
| WorkflowStatus, | ||
| SimStudioError | ||
| } from 'simstudio-ts-sdk'; | ||
|
|
||
| // Inicialización del cliente con seguridad de tipos | ||
| const client: SimStudioClient = new SimStudioClient({ | ||
| apiKey: process.env.SIM_API_KEY! | ||
| }); | ||
|
|
||
| // Ejecución de flujo de trabajo con seguridad de tipos | ||
| const result: WorkflowExecutionResult = await client.executeWorkflow('workflow-id', { | ||
| input: { | ||
| message: 'Hola, TypeScript!' | ||
| } | ||
| }); | ||
|
|
||
| // Verificación de estado con seguridad de tipos | ||
| const status: WorkflowStatus = await client.getWorkflowStatus('workflow-id'); | ||
| ``` | ||
| ## License | ||
| Apache-2.0 + limits.usage.limit.toFixed(2)); | ||
| console.log('Plan:', limits.usage.plan); | ||
| const percentUsed = (limits.usage.currentPeriodCost / limits.usage.limit) * 100; | ||
| console.log('Usage: ' + percentUsed.toFixed(1) + '%'); | ||
| if (percentUsed > 80) { | ||
| console.warn('⚠️ Warning: You are approaching your usage limit!'); | ||
| } | ||
| } catch (error) { | ||
| console.error('Error checking usage:', error); | ||
| } | ||
| } | ||
| checkUsage(); | ||
| ``` | ||
|
|
||
| ### Ejecución de flujo de trabajo en streaming | ||
|
|
||
| Ejecuta flujos de trabajo con respuestas en tiempo real: | ||
|
|
||
| ```typescript | ||
| import { SimStudioClient } from 'simstudio-ts-sdk'; | ||
| const client = new SimStudioClient({ | ||
| apiKey: process.env.SIM_API_KEY! | ||
| }); | ||
| async function executeWithStreaming() { | ||
| try { | ||
| // Enable streaming for specific block outputs | ||
| const result = await client.executeWorkflow('workflow-id', { | ||
| input: { message: 'Count to five' }, | ||
| stream: true, | ||
| selectedOutputs: ['agent1.content'] // Use blockName.attribute format | ||
| }); | ||
| console.log('Workflow result:', result); | ||
| } catch (error) { | ||
| console.error('Error:', error); | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| La respuesta en streaming sigue el formato de eventos enviados por el servidor (SSE): | ||
|
|
||
| ``` | ||
| data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":"One"} | ||
| data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":", two"} | ||
| data: {"event":"done","success":true,"output":{},"metadata":{"duration":610}} | ||
| data: [DONE] | ||
| ``` | ||
|
|
||
| **Ejemplo de streaming en React:** | ||
|
|
||
| ```typescript | ||
| import { useState, useEffect } from 'react'; | ||
| function StreamingWorkflow() { | ||
| const [output, setOutput] = useState(''); | ||
| const [loading, setLoading] = useState(false); | ||
| const executeStreaming = async () => { | ||
| setLoading(true); | ||
| setOutput(''); | ||
| // IMPORTANT: Make this API call from your backend server, not the browser | ||
| // Never expose your API key in client-side code | ||
| const response = await fetch('https://sim.ai/api/workflows/WORKFLOW_ID/execute', { | ||
| method: 'POST', | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| 'X-API-Key': process.env.SIM_API_KEY! // Server-side environment variable only | ||
| }, | ||
| body: JSON.stringify({ | ||
| message: 'Generate a story', | ||
| stream: true, | ||
| selectedOutputs: ['agent1.content'] | ||
| }) | ||
| }); | ||
| const reader = response.body?.getReader(); | ||
| const decoder = new TextDecoder(); | ||
| while (reader) { | ||
| const { done, value } = await reader.read(); | ||
| if (done) break; | ||
| const chunk = decoder.decode(value); | ||
| const lines = chunk.split('\n\n'); | ||
| for (const line of lines) { | ||
| if (line.startsWith('data: ')) { | ||
| const data = line.slice(6); | ||
| if (data === '[DONE]') { | ||
| setLoading(false); | ||
| break; | ||
| } | ||
| try { | ||
| const parsed = JSON.parse(data); | ||
| if (parsed.chunk) { | ||
| setOutput(prev => prev + parsed.chunk); | ||
| } else if (parsed.event === 'done') { | ||
| console.log('Execution complete:', parsed.metadata); | ||
| } | ||
| } catch (e) { | ||
| // Skip invalid JSON | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| return ( | ||
| <div> | ||
| <button onClick={executeStreaming} disabled={loading}> | ||
| {loading ? 'Generating...' : 'Start Streaming'} | ||
| </button> | ||
| <div style={{ whiteSpace: 'pre-wrap' }}>{output}</div> | ||
| </div> | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| ## Obtener tu clave API | ||
|
|
||
| <Steps> | ||
| <Step title="Inicia sesión en Sim"> | ||
| Navega a [Sim](https://sim.ai) e inicia sesión en tu cuenta. | ||
| </Step> | ||
| <Step title="Abre tu flujo de trabajo"> | ||
| Navega al flujo de trabajo que quieres ejecutar programáticamente. | ||
| </Step> | ||
| <Step title="Despliega tu flujo de trabajo"> | ||
| Haz clic en "Desplegar" para desplegar tu flujo de trabajo si aún no ha sido desplegado. | ||
| </Step> | ||
| <Step title="Crea o selecciona una clave API"> | ||
| Durante el proceso de despliegue, selecciona o crea una clave API. | ||
| </Step> | ||
| <Step title="Copia la clave API"> | ||
| Copia la clave API para usarla en tu aplicación TypeScript/JavaScript. | ||
| </Step> | ||
| </Steps> | ||
|
|
||
| <Callout type="warning"> | ||
| Mantén tu clave API segura y nunca la incluyas en el control de versiones. Utiliza variables de entorno o gestión de configuración segura. | ||
| </Callout> | ||
|
|
||
| ## Requisitos | ||
|
|
||
| - Node.js 16+ | ||
| - TypeScript 5.0+ (para proyectos TypeScript) | ||
|
|
||
| ## Soporte para TypeScript | ||
|
|
||
| El SDK está escrito en TypeScript y proporciona seguridad de tipos completa: | ||
|
|
||
| ```typescript | ||
| import { | ||
| SimStudioClient, | ||
| WorkflowExecutionResult, | ||
| WorkflowStatus, | ||
| SimStudioError | ||
| } from 'simstudio-ts-sdk'; | ||
| // Type-safe client initialization | ||
| const client: SimStudioClient = new SimStudioClient({ | ||
| apiKey: process.env.SIM_API_KEY! | ||
| }); | ||
| // Type-safe workflow execution | ||
| const result: WorkflowExecutionResult = await client.executeWorkflow('workflow-id', { | ||
| input: { | ||
| message: 'Hello, TypeScript!' | ||
| } | ||
| }); | ||
| // Type-safe status checking | ||
| const status: WorkflowStatus = await client.getWorkflowStatus('workflow-id'); | ||
| ``` | ||
|
|
||
| ## Licencia | ||
|
|
||
| Apache-2.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Duplicate content detected - this entire section appears to be a repetition of earlier content in the file. This will cause rendering issues and confusion for readers.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/docs/content/docs/es/sdks/typescript.mdx
Line: 1002:1292
Comment:
**logic:** Duplicate content detected - this entire section appears to be a repetition of earlier content in the file. This will cause rendering issues and confusion for readers.
How can I resolve this? If you propose a fix, please make it concise.|
1 Job Failed: CI / Test and Build / Test and Build failed on "Build application" |
Summary
Automated translation updates triggered by changes to documentation.
This PR was automatically created after content changes were made, updating translations for all supported languages using Lingo.dev AI translation engine.
Original trigger: feat(i18n): update translations (#1569)
feat(i18n): update translations
remove duplicate sections
fix typos
Commit: 8200e9a
Workflow: https://github.com/simstudioai/sim/actions/runs/18329306130
Type of Change
Testing
This PR includes automated translations for modified English documentation content:
What reviewers should focus on:
Checklist
Screenshots/Videos