Skip to content

Commit

Permalink
Release v0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Jan 23, 2024
1 parent 692395b commit 43f287a
Show file tree
Hide file tree
Showing 3 changed files with 1,184 additions and 22 deletions.
58 changes: 58 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,64 @@ func (c *Client) ExecutePromptStream(ctx context.Context, request *vellumclientg
)
}

// Executes a deployed Workflow and returns its outputs.
func (c *Client) ExecuteWorkflow(ctx context.Context, request *vellumclientgo.ExecuteWorkflowRequest) (*vellumclientgo.ExecuteWorkflowResponse, error) {
baseURL := "https://api.vellum.ai"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := baseURL + "/" + "v1/execute-workflow"

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
if err != nil {
return err
}
apiError := core.NewAPIError(statusCode, errors.New(string(raw)))
decoder := json.NewDecoder(bytes.NewReader(raw))
switch statusCode {
case 400:
value := new(vellumclientgo.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
case 404:
value := new(vellumclientgo.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
case 500:
value := new(vellumclientgo.InternalServerError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return apiError
}
return value
}
return apiError
}

var response *vellumclientgo.ExecuteWorkflowResponse
if err := c.caller.Call(
ctx,
&core.CallParams{
URL: endpointURL,
Method: http.MethodPost,
Headers: c.header,
Request: request,
Response: &response,
ErrorDecoder: errorDecoder,
},
); err != nil {
return nil, err
}
return response, nil
}

// Executes a deployed Workflow and streams back its results.
func (c *Client) ExecuteWorkflowStream(ctx context.Context, request *vellumclientgo.ExecuteWorkflowStreamRequest) (*core.Stream[vellumclientgo.WorkflowStreamEvent], error) {
baseURL := "https://predict.vellum.ai"
Expand Down
2 changes: 1 addition & 1 deletion core/client_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ func (c *ClientOptions) cloneHeader() http.Header {
headers := c.HTTPHeader.Clone()
headers.Set("X-Fern-Language", "Go")
headers.Set("X-Fern-SDK-Name", "github.com/vellum-ai/vellum-client-go")
headers.Set("X-Fern-SDK-Version", "v0.2.0")
headers.Set("X-Fern-SDK-Version", "v0.2.1")
return headers
}
Loading

0 comments on commit 43f287a

Please sign in to comment.