|
| 1 | +--- |
| 2 | +title: DSPy |
| 3 | +description: Run predictions using self-hosted DSPy programs |
| 4 | +--- |
| 5 | + |
| 6 | +import { BlockInfoCard } from "@/components/ui/block-info-card" |
| 7 | + |
| 8 | +<BlockInfoCard |
| 9 | + type="dspy" |
| 10 | + color="#1E293B" |
| 11 | +/> |
| 12 | + |
| 13 | +{/* MANUAL-CONTENT-START:intro */} |
| 14 | +[DSPy](https://github.com/stanford-oval/dspy) is an open-source framework for programming—rather than prompting—language models. DSPy enables you to build interpretable and modular LLM-powered agents using Python functions, structured modules, and declarative signatures, making it easy to compose, debug, and reliably deploy language model applications. |
| 15 | + |
| 16 | +With DSPy in Sim, you can: |
| 17 | + |
| 18 | +- **Run custom predictions**: Connect your self-hosted DSPy server and invoke prediction endpoints for a variety of natural language tasks. |
| 19 | +- **Chain of Thought and ReAct reasoning**: Leverage advanced DSPy modules for step-by-step reasoning, multi-turn dialogs, and action-observation loops. |
| 20 | +- **Integrate with your workflows**: Automate LLM predictions and reasoning as part of any Sim automation or agent routine. |
| 21 | +- **Provide custom endpoints and context**: Flexibly call your own DSPy-powered APIs with custom authentication, endpoints, input fields, and context. |
| 22 | + |
| 23 | +These features let your Sim agents access modular, interpretable LLM-based programs for tasks like question answering, document analysis, decision support, and more—where you remain in control of the model, data, and logic. |
| 24 | +{/* MANUAL-CONTENT-END */} |
| 25 | + |
| 26 | + |
| 27 | +## Usage Instructions |
| 28 | + |
| 29 | +Integrate with your self-hosted DSPy programs for LLM-powered predictions. Supports Predict, Chain of Thought, and ReAct agents. DSPy is the framework for programming—not prompting—language models. |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +## Tools |
| 34 | + |
| 35 | +### `dspy_predict` |
| 36 | + |
| 37 | +Run a prediction using a self-hosted DSPy program endpoint |
| 38 | + |
| 39 | +#### Input |
| 40 | + |
| 41 | +| Parameter | Type | Required | Description | |
| 42 | +| --------- | ---- | -------- | ----------- | |
| 43 | +| `baseUrl` | string | Yes | Base URL of the DSPy server \(e.g., https://your-dspy-server.com\) | |
| 44 | +| `apiKey` | string | No | API key for authentication \(if required by your server\) | |
| 45 | +| `endpoint` | string | No | API endpoint path \(defaults to /predict\) | |
| 46 | +| `input` | string | Yes | The input text to send to the DSPy program | |
| 47 | +| `inputField` | string | No | Name of the input field expected by the DSPy program \(defaults to "text"\) | |
| 48 | +| `context` | string | No | Additional context to provide to the DSPy program | |
| 49 | +| `additionalInputs` | json | No | Additional key-value pairs to include in the request body | |
| 50 | + |
| 51 | +#### Output |
| 52 | + |
| 53 | +| Parameter | Type | Description | |
| 54 | +| --------- | ---- | ----------- | |
| 55 | +| `answer` | string | The main output/answer from the DSPy program | |
| 56 | +| `reasoning` | string | The reasoning or rationale behind the answer \(if available\) | |
| 57 | +| `status` | string | Response status from the DSPy server \(success or error\) | |
| 58 | +| `rawOutput` | json | The complete raw output from the DSPy program \(result.toDict\(\)\) | |
| 59 | + |
| 60 | +### `dspy_chain_of_thought` |
| 61 | + |
| 62 | +#### Input |
| 63 | + |
| 64 | +| Parameter | Type | Required | Description | |
| 65 | +| --------- | ---- | -------- | ----------- | |
| 66 | + |
| 67 | +#### Output |
| 68 | + |
| 69 | +| Parameter | Type | Description | |
| 70 | +| --------- | ---- | ----------- | |
| 71 | +| `answer` | string | The answer/output from the DSPy program | |
| 72 | +| `reasoning` | string | The reasoning or rationale behind the answer | |
| 73 | +| `trajectory` | json | Step-by-step trajectory for ReAct \(thoughts, actions, observations\) | |
| 74 | +| `status` | string | Response status from the DSPy server | |
| 75 | +| `rawOutput` | json | Complete raw output from the DSPy program | |
| 76 | + |
| 77 | +### `dspy_react` |
| 78 | + |
| 79 | +Run a ReAct agent using a self-hosted DSPy ReAct program endpoint for multi-step reasoning and action |
| 80 | + |
| 81 | +#### Input |
| 82 | + |
| 83 | +| Parameter | Type | Required | Description | |
| 84 | +| --------- | ---- | -------- | ----------- | |
| 85 | +| `baseUrl` | string | Yes | Base URL of the DSPy server \(e.g., https://your-dspy-server.com\) | |
| 86 | +| `apiKey` | string | No | API key for authentication \(if required by your server\) | |
| 87 | +| `endpoint` | string | No | API endpoint path \(defaults to /predict\) | |
| 88 | +| `task` | string | Yes | The task or question for the ReAct agent to work on | |
| 89 | +| `context` | string | No | Additional context to provide for the task | |
| 90 | +| `maxIterations` | number | No | Maximum number of reasoning iterations \(defaults to server setting\) | |
| 91 | + |
| 92 | +#### Output |
| 93 | + |
| 94 | +| Parameter | Type | Description | |
| 95 | +| --------- | ---- | ----------- | |
| 96 | +| `answer` | string | The final answer or result from the ReAct agent | |
| 97 | +| `reasoning` | string | The overall reasoning summary from the agent | |
| 98 | +| `trajectory` | array | The step-by-step trajectory of thoughts, actions, and observations | |
| 99 | +| ↳ `thought` | string | The reasoning thought at this step | |
| 100 | +| ↳ `toolName` | string | The name of the tool/action called | |
| 101 | +| ↳ `toolArgs` | json | Arguments passed to the tool | |
| 102 | +| ↳ `observation` | string | The observation/result from the tool execution | |
| 103 | +| `status` | string | Response status from the DSPy server \(success or error\) | |
| 104 | +| `rawOutput` | json | The complete raw output from the DSPy program \(result.toDict\(\)\) | |
| 105 | + |
| 106 | + |
0 commit comments