Files
sim/packages
Priyanshu Solanki 4f69b171f2 feat(kb): Adding support for more tags to the KB (#2433)
* creating boolean, number and date tags with different equality matchings

* feat: add UI for tag field types with filter operators

- Update base-tags-modal with field type selector dropdown
- Update document-tags-modal with different input types per fieldType
- Update knowledge-tag-filters with operator dropdown and type-specific inputs
- Update search routes to support all tag slot types
- Update hook to use AllTagSlot type

* feat: add field type support to document-tag-entry component

- Add dropdown with all field types (Text, Number, Date, Boolean)
- Render different value inputs based on field type
- Update slot counting to include all field types (28 total)

* fix: resolve MAX_TAG_SLOTS error and z-index dropdown issue

- Replace MAX_TAG_SLOTS with totalSlots in document-tag-entry
- Add z-index to SelectContent in base-tags-modal for proper layering

* fix: handle non-text columns in getTagUsage query

- Only apply empty string check for text columns (tag1-tag7)
- Numeric/date/boolean columns only check IS NOT NULL
- Cast values to text for consistent output

* refactor: use EMCN components for KB UI

- Replace @/components/ui imports with @/components/emcn
- Use Combobox instead of Select for dropdowns
- Use EMCN Switch, Button, Input, Label components
- Remove unsupported 'size' prop from EMCN Button

* fix: layout for delete button next to date picker

- Change delete button from absolute to inline positioning
- Add proper column width (w-10) for delete button
- Add empty header cell for delete column
- Apply fix to both document-tag-entry and knowledge-tag-filters

* fix: clear value when switching tag field type

- Reset value to empty when changing type (e.g., boolean to text)
- Reset value when tag name changes and type differs
- Prevents 'true'/'false' from sticking in text inputs

* feat: add full support for number/date/boolean tag filtering in KB search

- Copy all tag types (number, date, boolean) from document to embedding records
- Update processDocumentTags to handle all field types with proper type conversion
- Add number/date/boolean columns to document queries in checkDocumentWriteAccess
- Update chunk creation to inherit all tag types from parent document
- Add getSearchResultFields helper for consistent query result selection
- Support structured filters with operators (eq, gt, lt, between, etc.)
- Fix search queries to include all 28 tag fields in results

* fixing tags import issue

* fix rm file

* reduced number to 3 and date to 2

* fixing lint

* fixed the prop size issue

* increased number from 3 to 5 and boolean from 7 to 2

* fixed number the sql stuff

* progress

* fix document tag and kb tag modals

* update datepicker emcn component

* fix ui

* progress on KB block tags UI

* fix issues with date filters

* fix execution parsing of types for KB tags

* remove migration before merge

* regen migrations

* fix tests and types

* address greptile comments

* fix more greptile comments

* fix filtering logic for multiple of same row

* fix tests

---------

Co-authored-by: priyanshu.solanki <priyanshu.solanki@saviynt.com>
Co-authored-by: Vikhyath Mondreti <vikhyath@simstudio.ai>
2025-12-19 21:00:35 -08:00
..

Sim SDKs

This directory contains the official SDKs for Sim, allowing developers to execute workflows programmatically from their applications.

Available SDKs

Package Installation Commands

  • TypeScript/JavaScript: npm install simstudio-ts-sdk
  • Python: pip install simstudio-sdk

🟢 TypeScript/JavaScript SDK (simstudio-ts-sdk)

Directory: ts-sdk/

The TypeScript SDK provides type-safe workflow execution for Node.js and browser environments.

Installation:

npm install simstudio-ts-sdk
# or 
yarn add simstudio-ts-sdk
# or
bun add simstudio-ts-sdk

Quick Start:

import { SimStudioClient } from 'simstudio-ts-sdk';

const client = new SimStudioClient({
  apiKey: 'your-api-key-here'
});

const result = await client.executeWorkflow('workflow-id', {
  input: { message: 'Hello, world!' }
});

🐍 Python SDK (simstudio-sdk)

Directory: python-sdk/

The Python SDK provides Pythonic workflow execution with comprehensive error handling and data classes.

Installation:

pip install simstudio-sdk

Quick Start:

from simstudio import SimStudioClient

client = SimStudioClient(api_key='your-api-key-here')

result = client.execute_workflow('workflow-id', 
    input_data={'message': 'Hello, world!'})

Core Features

Both SDKs provide the same core functionality:

Workflow Execution - Execute deployed workflows with optional input data
Status Checking - Check deployment status and workflow readiness
Error Handling - Comprehensive error handling with specific error codes
Timeout Support - Configurable timeouts for workflow execution
Input Validation - Validate workflows before execution
Type Safety - Full type definitions (TypeScript) and data classes (Python)

API Compatibility

Both SDKs are built on top of the same REST API endpoints:

  • POST /api/workflows/{id}/execute - Execute workflow (with or without input)
  • GET /api/workflows/{id}/status - Get workflow status

Authentication

Both SDKs use API key authentication via the X-API-Key header. You can obtain an API key by:

  1. Logging in to your Sim account
  2. Navigating to your workflow
  3. Clicking "Deploy" to deploy your workflow
  4. Creating or selecting an API key during deployment

Environment Variables

Both SDKs support environment variable configuration:

# Required
SIM_API_KEY=your-api-key-here

# Optional
SIM_BASE_URL=https://sim.ai  # or your custom domain

Error Handling

Both SDKs provide consistent error handling with these error codes:

Code Description
UNAUTHORIZED Invalid API key
TIMEOUT Request timed out
USAGE_LIMIT_EXCEEDED Account usage limit exceeded
INVALID_JSON Invalid JSON in request body
EXECUTION_ERROR General execution error
STATUS_ERROR Error getting workflow status

Examples

TypeScript Example

import { SimStudioClient, SimStudioError } from 'simstudio-ts-sdk';

const client = new SimStudioClient({
  apiKey: process.env.SIM_API_KEY!
});

try {
  // Check if workflow is ready
  const isReady = await client.validateWorkflow('workflow-id');
  if (!isReady) {
    throw new Error('Workflow not deployed');
  }

  // Execute workflow
  const result = await client.executeWorkflow('workflow-id', {
    input: { data: 'example' },
    timeout: 30000
  });

  if (result.success) {
    console.log('Output:', result.output);
  }
} catch (error) {
  if (error instanceof SimStudioError) {
    console.error(`Error ${error.code}: ${error.message}`);
  }
}

Python Example

from simstudio import SimStudioClient, SimStudioError
import os

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

try:
    # Check if workflow is ready
    is_ready = client.validate_workflow('workflow-id')
    if not is_ready:
        raise Exception('Workflow not deployed')

    # Execute workflow
    result = client.execute_workflow('workflow-id', 
        input_data={'data': 'example'},
        timeout=30.0)

    if result.success:
        print(f'Output: {result.output}')
        
except SimStudioError as error:
    print(f'Error {error.code}: {error}')

Development

Building the SDKs

TypeScript SDK:

cd packages/ts-sdk
bun install
bun run build

Python SDK:

cd packages/python-sdk
pip install -e ".[dev]"
python -m build

Running Examples

TypeScript:

cd packages/ts-sdk
SIM_API_KEY=your-key bun run examples/basic-usage.ts

Python:

cd packages/python-sdk
SIM_API_KEY=your-key python examples/basic_usage.py

Testing

TypeScript:

cd packages/ts-sdk
bun run test

Python:

cd packages/python-sdk
pytest

Publishing

The SDKs are automatically published to npm and PyPI when changes are pushed to the main branch. See Publishing Setup for details on:

  • Setting up GitHub secrets for automated publishing
  • Manual publishing instructions
  • Version management and semantic versioning
  • Troubleshooting common issues

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Add tests for your changes
  5. Run the test suite: bun run test (TypeScript) or pytest (Python)
  6. Update version numbers if needed
  7. Commit your changes: git commit -m 'Add amazing feature'
  8. Push to the branch: git push origin feature/amazing-feature
  9. Open a Pull Request

License

Both SDKs are licensed under the Apache-2.0 License. See the LICENSE file for details.

Support