mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-07 07:55:16 +02:00
feat: add examples to create workflow and use sdk
This commit is contained in:
parent
16587fd7e1
commit
f041e6030d
18 changed files with 1038 additions and 7 deletions
|
|
@ -1,6 +1,6 @@
|
|||
[project]
|
||||
name = "dograh-sdk"
|
||||
version = "0.1.2"
|
||||
version = "0.1.3"
|
||||
description = "Typed builder for Dograh voice-AI workflows"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ from __future__ import annotations
|
|||
from typing import Any
|
||||
|
||||
from dograh_sdk._generated_models import (
|
||||
CreateWorkflowRequest,
|
||||
CredentialResponse,
|
||||
DocumentListResponseSchema,
|
||||
InitiateCallRequest,
|
||||
|
|
@ -28,6 +29,11 @@ from dograh_sdk._generated_models import (
|
|||
class _GeneratedClient:
|
||||
# `DograhClient.__init__` installs `self._request` (see client.py).
|
||||
|
||||
def create_workflow(self, *, body: CreateWorkflowRequest) -> WorkflowResponse:
|
||||
"""Create a new workflow from a workflow definition."""
|
||||
data = self._request("POST", "/workflow/create/definition", json=body.model_dump(mode="json", exclude_none=True))
|
||||
return WorkflowResponse.model_validate(data)
|
||||
|
||||
def get_node_type(self, name: str) -> NodeSpec:
|
||||
"""Fetch a single node spec by name."""
|
||||
data = self._request("GET", f"/node-types/{name}")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# generated by datamodel-codegen:
|
||||
# filename: dograh-openapi-XXXXXX.json.oPRfLAwVZP
|
||||
# timestamp: 2026-04-21T02:15:12+00:00
|
||||
# filename: dograh-openapi-XXXXXX.json.YcuMTcSn5P
|
||||
# timestamp: 2026-04-24T08:26:45+00:00
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
|
@ -16,6 +16,11 @@ class CallDispositionCodes(BaseModel):
|
|||
)
|
||||
|
||||
|
||||
class CreateWorkflowRequest(BaseModel):
|
||||
name: Annotated[str, Field(title='Name')]
|
||||
workflow_definition: Annotated[dict[str, Any], Field(title='Workflow Definition')]
|
||||
|
||||
|
||||
class CreatedByResponse(BaseModel):
|
||||
"""
|
||||
Response schema for the user who created a tool.
|
||||
|
|
|
|||
4
sdk/typescript/package-lock.json
generated
4
sdk/typescript/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@dograh/sdk",
|
||||
"version": "0.1.1",
|
||||
"version": "0.1.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@dograh/sdk",
|
||||
"version": "0.1.1",
|
||||
"version": "0.1.3",
|
||||
"license": "BSD-2-Clause",
|
||||
"devDependencies": {
|
||||
"openapi-typescript": "^7.13.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@dograh/sdk",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"description": "Typed builder for Dograh voice-AI workflows",
|
||||
"license": "BSD-2-Clause",
|
||||
"author": "Zansat Technologies Private Limited",
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
// `_generated_models` (openapi-typescript output, --root-types).
|
||||
|
||||
import type {
|
||||
CreateWorkflowRequest,
|
||||
CredentialResponse,
|
||||
DocumentListResponseSchema,
|
||||
InitiateCallRequest,
|
||||
|
|
@ -26,6 +27,11 @@ export abstract class _GeneratedClient {
|
|||
opts?: { json?: unknown; params?: Record<string, unknown> },
|
||||
): Promise<T>;
|
||||
|
||||
/** Create a new workflow from a workflow definition. */
|
||||
async createWorkflow(opts: { body: CreateWorkflowRequest }): Promise<WorkflowResponse> {
|
||||
return this.request<WorkflowResponse>("POST", "/workflow/create/definition", { json: opts.body });
|
||||
}
|
||||
|
||||
/** Fetch a single node spec by name. */
|
||||
async getNodeType(name: string): Promise<NodeSpec> {
|
||||
return this.request<NodeSpec>("GET", `/node-types/${name}`);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,30 @@ export interface paths {
|
|||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/api/v1/workflow/create/definition": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: never;
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
get?: never;
|
||||
put?: never;
|
||||
/**
|
||||
* Create Workflow
|
||||
* @description Create a new workflow from the client
|
||||
*
|
||||
* Args:
|
||||
* request: The create workflow request
|
||||
* user: The user to create the workflow for
|
||||
*/
|
||||
post: operations["create_workflow_api_v1_workflow_create_definition_post"];
|
||||
delete?: never;
|
||||
options?: never;
|
||||
head?: never;
|
||||
patch?: never;
|
||||
trace?: never;
|
||||
};
|
||||
"/api/v1/workflow/fetch": {
|
||||
parameters: {
|
||||
query?: never;
|
||||
|
|
@ -246,6 +270,15 @@ export interface components {
|
|||
*/
|
||||
disposition_codes: string[];
|
||||
};
|
||||
/** CreateWorkflowRequest */
|
||||
CreateWorkflowRequest: {
|
||||
/** Name */
|
||||
name: string;
|
||||
/** Workflow Definition */
|
||||
workflow_definition: {
|
||||
[key: string]: unknown;
|
||||
};
|
||||
};
|
||||
/**
|
||||
* CreatedByResponse
|
||||
* @description Response schema for the user who created a tool.
|
||||
|
|
@ -714,6 +747,7 @@ export interface components {
|
|||
pathItems: never;
|
||||
}
|
||||
export type CallDispositionCodes = components['schemas']['CallDispositionCodes'];
|
||||
export type CreateWorkflowRequest = components['schemas']['CreateWorkflowRequest'];
|
||||
export type CreatedByResponse = components['schemas']['CreatedByResponse'];
|
||||
export type CredentialResponse = components['schemas']['CredentialResponse'];
|
||||
export type DisplayOptions = components['schemas']['DisplayOptions'];
|
||||
|
|
@ -781,6 +815,49 @@ export interface operations {
|
|||
};
|
||||
};
|
||||
};
|
||||
create_workflow_api_v1_workflow_create_definition_post: {
|
||||
parameters: {
|
||||
query?: never;
|
||||
header?: {
|
||||
authorization?: string | null;
|
||||
"X-API-Key"?: string | null;
|
||||
};
|
||||
path?: never;
|
||||
cookie?: never;
|
||||
};
|
||||
requestBody: {
|
||||
content: {
|
||||
"application/json": components["schemas"]["CreateWorkflowRequest"];
|
||||
};
|
||||
};
|
||||
responses: {
|
||||
/** @description Successful Response */
|
||||
200: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["WorkflowResponse"];
|
||||
};
|
||||
};
|
||||
/** @description Not found */
|
||||
404: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content?: never;
|
||||
};
|
||||
/** @description Validation Error */
|
||||
422: {
|
||||
headers: {
|
||||
[name: string]: unknown;
|
||||
};
|
||||
content: {
|
||||
"application/json": components["schemas"]["HTTPValidationError"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
get_workflows_api_v1_workflow_fetch_get: {
|
||||
parameters: {
|
||||
query?: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue