### Install @schift-io/sdk Source: https://github.com/schift-io/schift-ts/blob/main/README.md Install the Schift TypeScript SDK using npm. ```bash npm install @schift-io/sdk ``` -------------------------------- ### Quick Start Workflows Source: https://github.com/schift-io/schift-ts/blob/main/README.md Create and execute RAG pipelines as composable DAGs. ```typescript // Create from template or blank const wf = await client.workflows.create({ name: "My RAG Pipeline" }); // Run with inputs (multiple values supported) const result = await client.workflows.run(wf.id, { query: "maternity leave policy", language: "ko", }); console.log(result.outputs); ``` -------------------------------- ### Quick Start with Schift SDK Source: https://github.com/schift-io/schift-ts/blob/main/README.md Initialize the Schift client, create a bucket, upload a document, and perform a search. Bucket methods accept names or IDs. ```typescript import { Schift } from "@schift-io/sdk"; const client = new Schift({ apiKey: "sch_your_api_key" }); // Create or reuse a bucket, upload a document, then search it. // All bucket methods accept a name or ID — no need to track UUIDs. await client.createBucket({ name: "company-docs" }); const file = new File([await readFile("manual.pdf")], "manual.pdf", { type: "application/pdf", }); await client.db.upload("company-docs", { files: [file] }); const jobs = await client.listJobs({ bucket: "company-docs", limit: 5 }); const results = await client.bucketSearch("company-docs", { query: "refund policy", topK: 5, }); console.log(jobs[0]?.status ?? "queued"); console.log(results[0]); ``` -------------------------------- ### Manage Vector Collections Source: https://context7.com/schift-io/schift-ts/llms.txt Code examples for creating, listing, retrieving details, adding documents, searching, and deleting vector collections. ```typescript // Create collection const collection = await client.createCollection({ name: "my-collection", dimension: 1024, model: "openai/text-embedding-3-small", }); ``` ```typescript // List collections const collections = await client.listCollections(); ``` ```typescript // Get collection details and stats const details = await client.getCollection("collection-id"); const stats = await client.collectionStats("collection-id"); ``` ```typescript // Add documents (auto-embeds) await client.collectionAdd("my-collection", { documents: ["Document 1 text", "Document 2 text"], ids: ["doc1", "doc2"], metadata: [{ type: "faq" }, { type: "guide" }], model: "openai/text-embedding-3-small", }); ``` ```typescript // Search collection const results = await client.collectionSearch("my-collection", { query: "How does it work?", topK: 10, mode: "hybrid", rerank: true, }); ``` ```typescript // Delete collection await client.deleteCollection("collection-id"); ``` -------------------------------- ### Tool Calling for OpenAI Function Calling Source: https://context7.com/schift-io/schift-ts/llms.txt Generate tool definitions compatible with OpenAI's function calling. This example demonstrates how to integrate Schift's tool handling with OpenAI's chat completions. ```typescript import OpenAI from "openai"; import { Schift } from "@schift-io/sdk"; const schift = new Schift({ apiKey: "sch_xxx" }); const openai = new OpenAI(); const response = await openai.chat.completions.create({ model: "gpt-4o-mini", messages: [{ role: "user", content: "What's our refund policy?" }], tools: schift.tools.openai(), // Returns OpenAI-formatted tool definitions }); // When OpenAI calls the tool, handle it: const toolCall = response.choices[0].message.tool_calls?.[0]; if (toolCall) { const toolResult = await schift.tools.handle(toolCall); // toolResult is a JSON string ready to pass back to OpenAI } ``` -------------------------------- ### Create AI Agents with RAG and Tool Calling Source: https://context7.com/schift-io/schift-ts/llms.txt Build AI agents using the Schift SDK, integrating RAG for knowledge base access, memory, and tool calling. This example sets up a support agent that uses a RAG instance to answer questions. ```typescript import { Agent, RAG } from "@schift-io/sdk"; const schift = new Schift({ apiKey: process.env.SCHIFT_API_KEY! }); // Create RAG instance for knowledge base access const rag = new RAG({ bucket: "company-docs", topK: 5 }, schift.transport); const agent = new Agent({ name: "support-agent", instructions: "You are a helpful customer support agent. Use the knowledge base to answer questions.", model: "gpt-4o-mini", transport: schift.transport, // Required for Schift Cloud rag: rag, // Auto-registers as a tool tools: [], // Additional custom tools }); const result = await agent.run("How do I cancel my subscription?"); console.log(result.output); // Final answer console.log(result.steps); // Tool calls and intermediate steps ``` -------------------------------- ### Vercel AI SDK Integration with Schift Source: https://github.com/schift-io/schift-ts/blob/main/README.md Integrate Schift tools with the Vercel AI SDK for LLM routing and RAG. This example demonstrates generating text with a tool-calling model. ```typescript import { generateText } from "ai"; import { openai } from "@ai-sdk/openai"; import { Schift } from "@schift-io/sdk"; const schift = new Schift({ apiKey: process.env.SCHIFT_API_KEY! }); const result = await generateText({ model: openai("gpt-4o-mini"), prompt: "What changed in the latest billing policy?", tools: schift.tools.vercelAI(), maxSteps: 5, }); console.log(result.text); ``` -------------------------------- ### Track Document Processing Jobs Source: https://context7.com/schift-io/schift-ts/llms.txt Examples for listing jobs associated with a bucket, retrieving the status of a specific job, and performing actions like cancellation or reprocessing. ```typescript // List jobs for a bucket const jobs = await client.listJobs({ bucket: "company-docs", // Name or ID status: "processing", // Optional filter limit: 10, }); ``` ```typescript // Get job status const job = await client.getJob("job_id"); console.log(job.status); // "queued" | "processing" | "completed" | "failed" ``` ```typescript // Cancel or reprocess await client.cancelJob("job_id"); await client.reprocessJob("job_id"); ``` -------------------------------- ### Tool Calling Integration with Vercel AI SDK Source: https://context7.com/schift-io/schift-ts/llms.txt Integrate Schift's tool calling capabilities with the Vercel AI SDK. This example uses `generateText` and automatically handles tool execution up to a specified number of steps. ```typescript import { generateText } from "ai"; import { openai } from "@ai-sdk/openai"; import { Schift } from "@schift-io/sdk"; const schift = new Schift({ apiKey: process.env.SCHIFT_API_KEY! }); const result = await generateText({ model: openai("gpt-4o-mini"), prompt: "What changed in the latest billing policy?", tools: schift.tools.vercelAI(), // Tools with built-in execute functions maxSteps: 5, }); console.log(result.text); ``` -------------------------------- ### Tool Calling for Anthropic Claude Source: https://context7.com/schift-io/schift-ts/llms.txt Generate tool definitions for Anthropic Claude models. This example shows how to use Schift's tool definitions with the Anthropic SDK for message creation and tool use handling. ```typescript import Anthropic from "@anthropic-ai/sdk"; import { Schift } from "@schift-io/sdk"; const schift = new Schift({ apiKey: "sch_xxx" }); const anthropic = new Anthropic(); const response = await anthropic.messages.create({ model: "claude-sonnet-4-20250514", max_tokens: 1024, tools: schift.tools.anthropic(), // Returns Claude-formatted tool definitions messages: [{ role: "user", content: "Find termination clauses in the contract" }], }); // Handle tool use const toolUse = response.content.find(c => c.type === "tool_use"); if (toolUse) { const toolResult = await schift.tools.handle(toolUse); } ``` -------------------------------- ### Google Gen AI SDK Integration with Schift Source: https://github.com/schift-io/schift-ts/blob/main/README.md Integrate Schift tools with Google Gen AI for RAG chat. This example shows a two-turn conversation where the first turn involves a tool call to Schift. ```typescript import { GoogleGenAI } from "@google/genai"; import { Schift } from "@schift-io/sdk"; const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY }); const schift = new Schift({ apiKey: process.env.SCHIFT_API_KEY! }); const firstTurn = await ai.models.generateContent({ model: "gemini-2.5-flash", contents: "What changed in the latest billing policy?", config: { tools: schift.tools.googleGenAI(), }, }); const functionCall = firstTurn.functionCalls?.[0]; if (functionCall) { const functionResponsePart = await schift.tools.googleFunctionResponse({ name: functionCall.name, args: functionCall.args ?? {}, }); const secondTurn = await ai.models.generateContent({ model: "gemini-2.5-flash", contents: [ { role: "user", parts: [{ text: "What changed in the latest billing policy?" }] }, { role: "model", parts: [{ functionCall }] }, { role: "user", parts: [functionResponsePart] }, ], }); console.log(secondTurn.text); } ``` -------------------------------- ### Configure Schift Client Source: https://github.com/schift-io/schift-ts/blob/main/README.md Initialize the Schift client with custom configuration options. ```typescript const client = new Schift({ apiKey: "sch_...", // required baseUrl: "https://api.schift.io", // default timeout: 60_000, // default, in milliseconds }); ``` -------------------------------- ### Create and Manage Hosted Agents Source: https://context7.com/schift-io/schift-ts/llms.txt This section demonstrates how to create, interact with, and manage hosted agents, including streaming responses and performing CRUD operations. ```typescript const client = new Schift({ apiKey: "sch_xxx" }); ``` ```typescript // Create a managed agent const agent = await client.agents.create({ name: "CS Bot", instructions: "You are a customer support agent.", model: "gpt-4o-mini", ragConfig: { bucket: "support-docs" }, tools: [{ name: "lookup_order", description: "...", parameters: {} }], }); ``` ```typescript // Start a run const run = await client.agents.runs(agent.id).create({ message: "I need help with my order", metadata: { userId: "user_123" }, }); ``` ```typescript // Stream events for await (const event of client.agents.runs(agent.id).streamEvents(run.id)) { if (event.eventType === "message") { console.log(event.content); } } ``` ```typescript // Agent CRUD const agents = await client.agents.list(); const single = await client.agents.get(agent.id); await client.agents.update(agent.id, { name: "Updated Bot" }); await client.agents.delete(agent.id); ``` -------------------------------- ### Initialize WebSearch with BYOK Source: https://context7.com/schift-io/schift-ts/llms.txt Configures a standalone web search instance with a specific provider and API key, or integrates it as an agent tool. ```typescript import { WebSearch } from "@schift-io/sdk"; // BYOK with Tavily const webSearch = new WebSearch({ provider: "tavily", // "tavily", "serper", "brave", or "schift" providerApiKey: process.env.TAVILY_API_KEY!, maxResults: 5, }); const results = await webSearch.search("Schift AI agent framework updates"); // Or use as an agent tool const agent = new Agent({ name: "researcher", instructions: "You are a research assistant.", tools: [webSearch.asTool()], // Adds web_search tool transport: schift.transport, }); ``` -------------------------------- ### Initialize Schift Client with Environment Variable Source: https://github.com/schift-io/schift-ts/blob/main/README.md Initialize the Schift client using an API key stored in an environment variable. ```typescript const client = new Schift({ apiKey: process.env.SCHIFT_API_KEY! }); ``` -------------------------------- ### Client Initialization Source: https://context7.com/schift-io/schift-ts/llms.txt Initialize the Schift client with your API key. The client provides access to embeddings, search, RAG chat, workflows, and managed agents. ```APIDOC ## Client Initialization Initialize the Schift client with your API key. The client provides access to embeddings, search, RAG chat, workflows, and managed agents. ```typescript import { Schift } from "@schift-io/sdk"; const client = new Schift({ apiKey: "sch_your_api_key", // Required - get from Schift Dashboard baseUrl: "https://api.schift.io", // Optional - default API endpoint timeout: 60_000, // Optional - request timeout in ms }); // Or use environment variables const client = new Schift({ apiKey: process.env.SCHIFT_API_KEY! }); ``` ``` -------------------------------- ### Initialize Schift Client Source: https://context7.com/schift-io/schift-ts/llms.txt Initialize the Schift client with your API key. You can provide the API key directly or use environment variables. The baseUrl and timeout are optional parameters. ```typescript import { Schift } from "@schift-io/sdk"; const client = new Schift({ apiKey: "sch_your_api_key", // Required - get from Schift Dashboard baseUrl: "https://api.schift.io", // Optional - default API endpoint timeout: 60_000, // Optional - request timeout in ms }); ``` ```typescript // Or use environment variables const client = new Schift({ apiKey: process.env.SCHIFT_API_KEY! }); ``` -------------------------------- ### RAG Chat with Source Citations Source: https://context7.com/schift-io/schift-ts/llms.txt Perform a RAG chat by searching a bucket and generating an AI answer with source citations in a single call. Customizable with model, topK, system prompt, temperature, and maxTokens. ```typescript const response = await client.chat({ bucket: "company-docs", // Bucket name or ID message: "How do I reset my password?", model: "openai/gpt-4o-mini", // Optional - LLM model topK: 5, // Optional - context chunks systemPrompt: "You are a helpful assistant.", // Optional temperature: 0.7, // Optional maxTokens: 1000, // Optional }); ``` -------------------------------- ### Upload Documents to Bucket Source: https://context7.com/schift-io/schift-ts/llms.txt Upload files to a named bucket. The bucket is created if it doesn't exist. Documents are automatically processed (OCR, chunking, embedding). Requires `fs/promises` for reading files. ```typescript import { readFile } from "fs/promises"; // Create or reuse a bucket, then upload files await client.createBucket({ name: "company-docs" }); const pdfBuffer = await readFile("manual.pdf"); const file = new File([pdfBuffer], "manual.pdf", { type: "application/pdf" }); const result = await client.db.upload("company-docs", { files: [file] }); ``` -------------------------------- ### Import and Export Workflows via YAML Source: https://github.com/schift-io/schift-ts/blob/main/README.md Serialize and deserialize workflow definitions using YAML. ```typescript // Export const yaml = await client.workflows.exportYaml(wf.id); // Import from YAML string const imported = await client.workflows.importYaml(yamlString); ``` -------------------------------- ### Handle SDK Errors Source: https://github.com/schift-io/schift-ts/blob/main/README.md Use try-catch blocks to differentiate between authentication, quota, and general API errors. ```typescript import { Schift, AuthError, QuotaError, SchiftError } from "@schift-io/sdk"; try { await client.embed({ text: "test" }); } catch (err) { if (err instanceof AuthError) { // 401: Invalid or expired API key } else if (err instanceof QuotaError) { // 402: Insufficient credits } else if (err instanceof SchiftError) { // Other API errors (403, 422, 429, 500, 502) console.error(err.message, err.statusCode); } } ``` -------------------------------- ### Build Workflows with WorkflowBuilder Source: https://github.com/schift-io/schift-ts/blob/main/README.md Construct complex graphs locally using a fluent API before deploying to the API. ```typescript import { WorkflowBuilder } from "@schift-io/sdk"; const request = new WorkflowBuilder("My RAG Pipeline") .description("Retrieval-augmented generation") .addBlock("start", { type: "start" }) .addBlock("retriever", { type: "retriever", config: { collection: "my-docs", top_k: 5 }, }) .addBlock("prompt", { type: "prompt_template", config: { template: "Context:\n{{results}}\n\nQ: {{query}}" }, }) .addBlock("llm", { type: "llm", config: { model: "openai/gpt-4o-mini" }, }) .addBlock("end", { type: "end" }) .connect("start", "retriever") .connect("retriever", "prompt") .connect("prompt", "llm") .connect("llm", "end") .build(); const wf = await client.workflows.create(request); ``` -------------------------------- ### Export and Import Workflows as YAML Source: https://context7.com/schift-io/schift-ts/llms.txt Use these functions to export existing workflows to YAML format for version control or import YAML content to create new workflows. ```typescript // Export workflow to YAML const yaml = await client.workflows.exportYaml(wf.id); console.log(yaml); ``` ```typescript // Import workflow from YAML const yamlContent = ` version: 1 name: My RAG Pipeline blocks: - id: start type: start - id: retriever type: retriever config: collection: my-docs top_k: 5 - id: end type: end edges: - source: start target: retriever - source: retriever target: end `; const imported = await client.workflows.importYaml(yamlContent); ``` -------------------------------- ### Perform Web Search with BYOK Provider Source: https://github.com/schift-io/schift-ts/blob/main/README.md Perform a web search using a Bring Your Own Key (BYOK) provider like Tavily. Configure the provider, API key, and maximum results. ```typescript // BYOK provider for direct web search import { WebSearch } from "@schift-io/sdk"; const webSearch = new WebSearch({ provider: "tavily", providerApiKey: process.env.TAVILY_API_KEY!, maxResults: 5, }); const fresh = await webSearch.search("Schift framework launch updates"); ``` -------------------------------- ### Integrate Schift with Mastra Source: https://github.com/schift-io/schift-ts/blob/main/README.md Wrap the Schift search client within a Mastra tool to enable RAG capabilities in your agent stack. ```typescript import { Agent } from "@mastra/core/agent"; import { createTool } from "@mastra/core/tools"; import { openai } from "@ai-sdk/openai"; import { z } from "zod"; import { Schift } from "@schift-io/sdk"; const client = new Schift({ apiKey: process.env.SCHIFT_API_KEY! }); const schiftSearchTool = createTool({ id: "schift-search", description: "Retrieve context from a Schift collection.", inputSchema: z.object({ collection: z.string(), query: z.string(), topK: z.number().int().min(1).max(10).default(5), }), execute: async ({ context }) => ({ results: await client.search({ collection: context.collection, query: context.query, topK: context.topK, mode: "hybrid", }), }), }); const agent = new Agent({ name: "docs-agent", instructions: "Use schift-search before answering document questions.", model: openai("gpt-4o-mini"), tools: { schiftSearchTool }, }); ``` -------------------------------- ### Build RAG Pipelines with WorkflowBuilder Source: https://context7.com/schift-io/schift-ts/llms.txt Constructs a RAG pipeline as a composable DAG using a fluent builder API. ```typescript import { Schift, WorkflowBuilder } from "@schift-io/sdk"; const client = new Schift({ apiKey: "sch_xxx" }); const request = new WorkflowBuilder("My RAG Pipeline") .description("Retrieval-augmented generation workflow") .addBlock("start", { type: "start" }) .addBlock("retriever", { type: "retriever", config: { collection: "my-docs", top_k: 5, rerank: true }, }) .addBlock("prompt", { type: "prompt_template", config: { template: "Context:\n{{results}}\n\nQ: {{query}}" }, }) .addBlock("llm", { type: "llm", config: { model: "openai/gpt-4o-mini", temperature: 0.7 }, }) .addBlock("end", { type: "end" }) .connect("start", "retriever") .connect("retriever", "prompt") .connect("prompt", "llm") .connect("llm", "end") .build(); const workflow = await client.workflows.create(request); ``` -------------------------------- ### Handle API Errors with Typed Error Classes Source: https://context7.com/schift-io/schift-ts/llms.txt Demonstrates how to catch and handle specific API errors like authentication failures, quota exceeded, and other general API errors using provided error classes. ```typescript import { Schift, AuthError, QuotaError, SchiftError } from "@schift-io/sdk"; ``` ```typescript try { await client.embed({ text: "test" }); } catch (err) { if (err instanceof AuthError) { // 401: Invalid or expired API key console.error("Authentication failed:", err.message); } else if (err instanceof QuotaError) { // 402: Insufficient credits console.error("Quota exceeded:", err.message); } else if (err instanceof SchiftError) { // Other API errors (403, 422, 429, 500, 502) console.error(`API error ${err.statusCode}:`, err.message); } } ``` -------------------------------- ### Perform Web Search for Real-time Information Source: https://context7.com/schift-io/schift-ts/llms.txt Search the web for up-to-date information using the Schift Cloud. This function returns an array of search results, each containing a title, URL, and snippet. ```typescript const results = await client.webSearch("latest AI regulations 2026", 5); results.forEach(r => { console.log(r.title, r.url, r.snippet); }); // Results: Array<{ title: string, url: string, snippet: string }> ``` -------------------------------- ### Bucket Upload Source: https://context7.com/schift-io/schift-ts/llms.txt Upload documents to a named bucket. Creates the bucket if it doesn't exist. Documents are automatically processed (OCR, chunking, embedding). ```APIDOC ## Bucket Upload Upload documents to a named bucket. Creates the bucket if it doesn't exist. Documents are automatically processed (OCR, chunking, embedding). ```typescript import { readFile } from "fs/promises"; // Create or reuse a bucket, then upload files await client.createBucket({ name: "company-docs" }); const pdfBuffer = await readFile("manual.pdf"); const file = new File([pdfBuffer], "manual.pdf", { type: "application/pdf" }); const result = await client.db.upload("company-docs", { files: [file] }); // Result: { // bucket_id: "uuid", // bucket_name: "company-docs", // uploaded: [{ fileId, filename, bytes, mimeType, status }] // } ``` ``` -------------------------------- ### RAG Chat Source: https://context7.com/schift-io/schift-ts/llms.txt Search a bucket and generate an AI answer with source citations in one call. ```APIDOC ## RAG Chat Search a bucket and generate an AI answer with source citations in one call. ```typescript const response = await client.chat({ bucket: "company-docs", // Bucket name or ID message: "How do I reset my password?", model: "openai/gpt-4o-mini", // Optional - LLM model topK: 5, // Optional - context chunks systemPrompt: "You are a helpful assistant.", // Optional temperature: 0.7, // Optional maxTokens: 1000, // Optional }); // Response: { // reply: "To reset your password, go to Settings > Security...", // sources: [{ id, score, text }], // model: "openai/gpt-4o-mini" // } ``` ``` -------------------------------- ### Perform Web Search with Schift Cloud Source: https://github.com/schift-io/schift-ts/blob/main/README.md Perform a web search using Schift Cloud's web search capabilities. Specify the query and the maximum number of results. ```typescript // Schift Cloud web search const results = await client.webSearch("latest AI regulations 2026", 5); results.forEach((r) => { console.log(r.title, r.url); }); ``` -------------------------------- ### Manage Workflows via Workflow Client Source: https://context7.com/schift-io/schift-ts/llms.txt Provides methods to create, modify, validate, and execute workflows programmatically. ```typescript const client = new Schift({ apiKey: "sch_xxx" }); // Create workflow const wf = await client.workflows.create({ name: "My Pipeline" }); // Add blocks incrementally const retriever = await client.workflows.addBlock(wf.id, { type: "retriever", title: "Search Docs", config: { collection: "my-docs", top_k: 5 }, }); const llm = await client.workflows.addBlock(wf.id, { type: "llm", config: { model: "openai/gpt-4o-mini" }, }); // Connect blocks await client.workflows.addEdge(wf.id, { source: retriever.id, target: llm.id, }); // Validate and run const validation = await client.workflows.validate(wf.id); if (validation.valid) { const run = await client.workflows.run(wf.id, { query: "What is our refund policy?", }); console.log(run.outputs); } // CRUD operations const workflows = await client.workflows.list(); const single = await client.workflows.get(wf.id); await client.workflows.update(wf.id, { name: "Renamed Pipeline" }); await client.workflows.delete(wf.id); ``` -------------------------------- ### Perform RAG Operations Source: https://context7.com/schift-io/schift-ts/llms.txt Executes semantic search and chat over a specified bucket, or exposes the functionality as an agent tool. ```typescript import { RAG } from "@schift-io/sdk"; const rag = new RAG({ bucket: "legal-docs", topK: 10 }, schift.transport); // Semantic search const results = await rag.search("force majeure clause"); // Returns: Array<{ text, score, metadata }> // RAG chat const answer = await rag.chat("What are the termination conditions?"); // Returns: { answer: string, sources: Array<{ text, metadata }> } // Use as agent tool const tool = rag.asTool("legal_search"); // Custom tool name ``` -------------------------------- ### Manage Graph Edges for Document Relationships Source: https://context7.com/schift-io/schift-ts/llms.txt Code snippets for adding, listing, and deleting relationship edges between documents within a bucket, and retrieving the bucket graph. ```typescript // Add edges await client.addEdges("my-bucket", [ { source: "doc_A", target: "doc_B", relation: "follows" }, { source: "doc_B", target: "doc_C", relation: "supersedes", weight: 0.8 }, ]); ``` ```typescript // List edges for a node const edges = await client.listEdges("my-bucket", "doc_A", { direction: "outgoing", // "incoming", "outgoing", or "both" relation: "follows", // Optional filter }); ``` ```typescript // Delete an edge await client.deleteEdge("my-bucket", "doc_A", "doc_B", "follows"); ``` ```typescript // Get bucket graph const graph = await client.bucketGraph("my-bucket", "query text", 10); ``` -------------------------------- ### Validate and Inspect Workflows Source: https://github.com/schift-io/schift-ts/blob/main/README.md Check graph validity and retrieve available workflow components. ```typescript // Validate graph const { valid, errors } = await client.workflows.validate(wf.id); // List available block types const blockTypes = await client.workflows.getBlockTypes(); // List available templates const templates = await client.workflows.getTemplates(); ``` -------------------------------- ### Manage Workflow Blocks and Edges Source: https://github.com/schift-io/schift-ts/blob/main/README.md Dynamically add, connect, or remove blocks within a workflow graph. ```typescript // Add blocks const retriever = await client.workflows.addBlock(wf.id, { type: "retriever", title: "Search Docs", config: { collection: "my-docs", top_k: 5, rerank: true }, }); const llm = await client.workflows.addBlock(wf.id, { type: "llm", config: { model: "openai/gpt-4o-mini", // or "anthropic/claude-sonnet-4-20250514", "gemini-2.5-flash" temperature: 0.7, }, }); // Connect blocks await client.workflows.addEdge(wf.id, { source: retriever.id, target: llm.id, }); // Remove await client.workflows.removeBlock(wf.id, retriever.id); await client.workflows.removeEdge(wf.id, edgeId); ``` -------------------------------- ### Manage Collections Source: https://github.com/schift-io/schift-ts/blob/main/README.md Perform CRUD operations on collections using the Schift client. ```typescript // List all collections const collections = await client.listCollections(); // Get collection details const col = await client.getCollection("collection-id"); // Delete collection await client.deleteCollection("collection-id"); ``` -------------------------------- ### Execute DeepResearch Source: https://context7.com/schift-io/schift-ts/llms.txt Performs iterative web research with query refinement and report synthesis using a custom LLM function. ```typescript import { DeepResearch } from "@schift-io/sdk"; // LLM function for analysis const llmFn = async (messages: Array<{ role: string; content: string }>) => { const resp = await fetch("https://api.openai.com/v1/chat/completions", { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${process.env.OPENAI_API_KEY}`, }, body: JSON.stringify({ model: "gpt-4o-mini", messages, }), }); const data = await resp.json(); return data.choices[0].message.content; }; const research = new DeepResearch({ webSearch: { provider: "tavily", providerApiKey: "tvly-xxx" }, queryModel: "gpt-4o-mini", synthesisModel: "gpt-4o", maxIterations: 5, resultsPerSearch: 5, queriesPerIteration: 2, }, llmFn); const report = await research.run("AI agent framework trends 2026"); console.log(report.answer); // Synthesized report console.log(report.sources); // Array of web search results console.log(report.iterations); // Number of research iterations console.log(report.totalQueries); // Total queries executed ``` -------------------------------- ### Stream RAG Chat Responses with Server-Sent Events Source: https://context7.com/schift-io/schift-ts/llms.txt Stream chat responses from a RAG system using Server-Sent Events for real-time output. Handles different event types like sources, chunks, completion, and errors. ```typescript for await (const event of client.chatStream({ bucket: "company-docs", message: "Summarize the Q4 report", })) { switch (event.type) { case "sources": console.log("Found sources:", event.sources); break; case "chunk": process.stdout.write(event.content ?? ""); break; case "done": console.log("\n--- Complete ---"); break; case "error": console.error("Error:", event.message); break; } } ``` -------------------------------- ### Bucket Search Source: https://context7.com/schift-io/schift-ts/llms.txt Search within a specific bucket by name or ID. ```APIDOC ## Bucket Search Search within a specific bucket by name or ID. ```typescript const results = await client.bucketSearch("company-docs", { query: "refund policy", topK: 5, mode: "hybrid", // "vector" or "hybrid" rerank: true, }); // Returns matching documents with scores and metadata ``` ``` -------------------------------- ### Generate Embeddings for Batch Texts Source: https://github.com/schift-io/schift-ts/blob/main/README.md Generate embeddings for a batch of texts (up to 2048). Specify the model for embedding. ```typescript // Batch (up to 2048 texts) const batch = await client.embedBatch({ texts: ["doc 1", "doc 2", "doc 3"], model: "gemini/text-embedding-004", }); // batch: { embeddings: number[][], model: string, dimensions: number, usage: { tokens, count } } ``` -------------------------------- ### Generate Embeddings for Single Text Source: https://github.com/schift-io/schift-ts/blob/main/README.md Generate an embedding for a single piece of text. Optional parameters include model, dimensions, and dimensions. ```typescript // Single text const resp = await client.embed({ text: "Search query", model: "openai/text-embedding-3-small", // optional dimensions: 1024, // optional }); // resp: { embedding: number[], model: string, dimensions: number, usage: { tokens: number } } ``` -------------------------------- ### Embeddings - Batch Source: https://context7.com/schift-io/schift-ts/llms.txt Embed multiple texts in a single request (up to 2048 texts per batch). ```APIDOC ## Embeddings - Batch Embed multiple texts in a single request (up to 2048 texts per batch). ```typescript const response = await client.embedBatch({ texts: [ "First document content", "Second document content", "Third document content" ], model: "gemini/text-embedding-004", // Optional dimensions: 768, // Optional }); // Response: // { // embeddings: number[][], // Array of vectors // model: "gemini/text-embedding-004", // dimensions: 768, // usage: { tokens: 15, count: 3 } // } ``` ``` -------------------------------- ### Search Collection with Hybrid Mode Source: https://context7.com/schift-io/schift-ts/llms.txt Search a vector collection using hybrid search (keyword and vector) with optional reranking. Metadata filtering is supported. ```typescript const results = await client.search({ query: "How does projection work?", collection: "my-docs", topK: 10, // Number of results mode: "hybrid", // "vector" or "hybrid" rerank: true, // Enable reranking rerankTopK: 5, // Results after reranking filter: { category: "technical" }, // Metadata filter }); ``` -------------------------------- ### Search within a Bucket Source: https://context7.com/schift-io/schift-ts/llms.txt Search for documents within a specific bucket by name or ID. Supports hybrid search and reranking. ```typescript const results = await client.bucketSearch("company-docs", { query: "refund policy", topK: 5, mode: "hybrid", // "vector" or "hybrid" rerank: true, }); ``` -------------------------------- ### Collection Search Source: https://context7.com/schift-io/schift-ts/llms.txt Search through a vector collection with optional hybrid search and reranking. ```APIDOC ## Collection Search Search through a vector collection with optional hybrid search and reranking. ```typescript const results = await client.search({ query: "How does projection work?", collection: "my-docs", topK: 10, // Number of results mode: "hybrid", // "vector" or "hybrid" rerank: true, // Enable reranking rerankTopK: 5, // Results after reranking filter: { category: "technical" }, // Metadata filter }); // Results: Array<{ // id: string, // score: number, // modality?: "text" | "image" | "audio" | "video" | "document", // metadata?: Record // }> ``` ``` -------------------------------- ### Workflow CRUD Operations Source: https://github.com/schift-io/schift-ts/blob/main/README.md Manage the lifecycle of workflow definitions. ```typescript const wf = await client.workflows.create({ name: "Pipeline" }); const all = await client.workflows.list(); const one = await client.workflows.get(wf.id); const updated = await client.workflows.update(wf.id, { name: "Renamed" }); await client.workflows.delete(wf.id); ``` -------------------------------- ### Embeddings - Single Text Source: https://context7.com/schift-io/schift-ts/llms.txt Generate embeddings for a single text string. Supports multiple models with automatic projection to a canonical 1024-dimensional space. ```APIDOC ## Embeddings - Single Text Generate embeddings for a single text string. Supports multiple models with automatic projection to a canonical 1024-dimensional space. ```typescript const response = await client.embed({ text: "How does vector search work?", model: "openai/text-embedding-3-small", // Optional - defaults to schift-embed-1 dimensions: 1024, // Optional - output dimensions taskType: "retrieval_query", // Optional - retrieval_document, semantic_similarity, etc. }); // Response: // { // embedding: number[], // 1024-dimensional vector // model: "openai/text-embedding-3-small", // dimensions: 1024, // usage: { tokens: 6 } // } ``` ``` -------------------------------- ### Perform Collection Search Source: https://github.com/schift-io/schift-ts/blob/main/README.md Search within a specified collection for relevant documents based on a query. Returns results with id, score, modality, and optional metadata. ```typescript const results = await client.search({ query: "How does projection work?", collection: "my-docs", topK: 10, }); // results: Array<{ id, score, modality, metadata? }> ``` -------------------------------- ### Generate Embeddings for Single Text Source: https://context7.com/schift-io/schift-ts/llms.txt Generate embeddings for a single text string using a specified model. The output can be projected to a canonical dimension. Supports various task types. ```typescript const response = await client.embed({ text: "How does vector search work?", model: "openai/text-embedding-3-small", // Optional - defaults to schift-embed-1 dimensions: 1024, // Optional - output dimensions taskType: "retrieval_query", // Optional - retrieval_document, semantic_similarity, etc. }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.