Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/docs/content/docs/de/sdks/python.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ Behandeln Sie verschiedene Fehlertypen, die während der Workflow-Ausführung au
from simstudio import SimStudioClient, SimStudioError
import os

client = SimStudioClient(api_key=os.getenv("SIM_API_KEY"))
client = SimStudioClient(api_key=os.getenv("SIM_API_KEY"))

def execute_with_error_handling():
try:
Expand Down Expand Up @@ -600,7 +600,7 @@ Führe Workflows mit Echtzeit-Streaming-Antworten aus:
from simstudio import SimStudioClient
import os

client = SimStudioClient(api_key=os.getenv("SIM_API_KEY"))
client = SimStudioClient(api_key=os.getenv("SIM_API_KEY"))

def execute_with_streaming():
"""Execute workflow with streaming enabled."""
Expand Down
308 changes: 305 additions & 3 deletions apps/docs/content/docs/de/sdks/typescript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,9 @@ async function checkUsage() {

Execute workflows with real-time streaming responses:

```typescript
```

typescript
import { SimStudioClient } from 'simstudio-ts-sdk';
Comment on lines +824 to 827
Copy link
Contributor

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.

Suggested change
```
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.


const client = new SimStudioClient({
Expand All @@ -842,23 +844,28 @@ async function executeWithStreaming() {
console.error('Fehler:', error);
}
}

```

The streaming response follows the Server-Sent Events (SSE) format:

```

data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":"One"}

data: {"blockId":"7b7735b9-19e5-4bd6-818b-46aae2596e9f","chunk":", zwei"}

data: {"event":"done","success":true,"output":{},"metadata":{"duration":610}}

data: [DONE]

```

**React Streaming Example:**

```typescript
```

typescript
import { useState, useEffect } from 'react';
Comment on lines +866 to 869
Copy link
Contributor

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.

Suggested change
```
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.


function StreamingWorkflow() {
Expand Down Expand Up @@ -926,6 +933,7 @@ function StreamingWorkflow() {
</div>
);
}

```

## Getting Your API Key
Expand Down Expand Up @@ -961,7 +969,9 @@ function StreamingWorkflow() {

The SDK is written in TypeScript and provides full type safety:

```typescript
```

typescript
import {
Comment on lines +972 to 975
Copy link
Contributor

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. Language identifier must be on the same line as opening backticks.

Suggested change
```
typescript
import {
```typescript
import {
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/docs/content/docs/de/sdks/typescript.mdx
Line: 972:975

Comment:
**syntax:** Code block syntax is broken. Language identifier must be on the same line as opening backticks.

```suggestion
```typescript
import {
```

How can I resolve this? If you propose a fix, please make it concise.

SimStudioClient,
WorkflowExecutionResult,
Expand All @@ -987,4 +997,296 @@ const status: WorkflowStatus = await client.getWorkflowStatus('workflow-id');

## License

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('Execution complete:', parsed.metadata);
}
} catch (e) {
// Skip invalid JSON
}
}
}
}
};

return (
<div>
<button onClick={executeStreaming} disabled={loading}>
{loading ? 'Generiere...' : 'Streaming starten'}
</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';

// Typsichere Client-Initialisierung
const client: SimStudioClient = new SimStudioClient({
apiKey: process.env.SIM_API_KEY!
});

// Typsichere Workflow-Ausführung
const result: WorkflowExecutionResult = await client.executeWorkflow('workflow-id', {
input: {
message: 'Hallo, TypeScript!'
}
});

// Typsichere Statusprüfung
const status: WorkflowStatus = await client.getWorkflowStatus('workflow-id');
```

## License

Apache-2.0 + limits.usage.limit.toFixed(2));
Copy link
Contributor

Choose a reason for hiding this comment

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

syntax: Incomplete line with code fragment 'Apache-2.0 + limits.usage.limit.toFixed(2));' appears to be corrupted content that should be removed.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/docs/content/docs/de/sdks/typescript.mdx
Line: 1105:1105

Comment:
**syntax:** Incomplete line with code fragment 'Apache-2.0 + limits.usage.limit.toFixed(2));' appears to be corrupted content that should be removed.

How can I resolve this? If you propose a fix, please make it concise.

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();
```

### Streaming-Workflow-Ausführung

Führen Sie Workflows mit Echtzeit-Streaming-Antworten aus:

```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);
}
}
```

Die Streaming-Antwort folgt dem Server-Sent Events (SSE) Format:

```
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]
```

**React Streaming-Beispiel:**

```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>
);
}
```

## Ihren API-Schlüssel erhalten

<Steps>
<Step title="Bei Sim anmelden">
Navigieren Sie zu [Sim](https://sim.ai) und melden Sie sich bei Ihrem Konto an.
</Step>
<Step title="Öffnen Sie Ihren Workflow">
Navigieren Sie zu dem Workflow, den Sie programmatisch ausführen möchten.
</Step>
<Step title="Deployen Sie Ihren Workflow">
Klicken Sie auf "Deploy", um Ihren Workflow zu deployen, falls dies noch nicht geschehen ist.
</Step>
<Step title="Erstellen oder wählen Sie einen API-Schlüssel">
Wählen Sie während des Deployment-Prozesses einen API-Schlüssel aus oder erstellen Sie einen neuen.
</Step>
<Step title="Kopieren Sie den API-Schlüssel">
Kopieren Sie den API-Schlüssel zur Verwendung in Ihrer TypeScript/JavaScript-Anwendung.
</Step>
</Steps>

<Callout type="warning">
Halte deinen API-Schlüssel sicher und committe ihn niemals in die Versionskontrolle. Verwende Umgebungsvariablen oder sicheres Konfigurationsmanagement.
</Callout>

## Anforderungen

- Node.js 16+
- TypeScript 5.0+ (für TypeScript-Projekte)

## TypeScript-Unterstützung

Das SDK ist in TypeScript geschrieben und bietet vollständige Typsicherheit:

```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');
```

## Lizenz

Apache-2.0
Comment on lines +1000 to 1292
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: This entire section duplicates content from earlier in the file (streaming examples, API key instructions, license). The duplication creates confusion and should be removed to maintain clean documentation structure.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/docs/content/docs/de/sdks/typescript.mdx
Line: 1000:1292

Comment:
**logic:** This entire section duplicates content from earlier in the file (streaming examples, API key instructions, license). The duplication creates confusion and should be removed to maintain clean documentation structure.

How can I resolve this? If you propose a fix, please make it concise.

2 changes: 1 addition & 1 deletion apps/docs/content/docs/es/sdks/python.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ Ejecuta flujos de trabajo con respuestas en tiempo real:
from simstudio import SimStudioClient
import os

client = SimStudioClient(api_key=os.getenv("SIM_API_KEY"))
client = SimStudioClient(api_key=os.getenv("SIM_API_KEY"))

def execute_with_streaming():
"""Execute workflow with streaming enabled."""
Expand Down
Loading
Loading