Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c028dfb0ed | |||
| 214fd02b3b | |||
| 3167966b98 |
46
CHANGELOG.md
46
CHANGELOG.md
@@ -1,3 +1,49 @@
|
||||
## v1.3.0 — 2026-04-03
|
||||
|
||||
Upstream sync with Python SDK v2.3.0. Updates workflow registration model
|
||||
to reflect the managed deployment architecture and removes the deprecated
|
||||
workers endpoint.
|
||||
|
||||
### Added
|
||||
|
||||
- **`workflow.CodeDefinition`** — workflow interface metadata type with
|
||||
input/output schemas, signal/query/update handler definitions,
|
||||
determinism flag, and execution timeout.
|
||||
- **`workflow.SignalDefinition`**, **`QueryDefinition`**,
|
||||
**`UpdateDefinition`** — handler descriptor types.
|
||||
- **`Registration.Definition`** — code definition field on workflow
|
||||
registrations.
|
||||
- **`Registration.DeploymentID`** — replaces the worker/task-queue model
|
||||
with managed deployment references.
|
||||
- **`Registration.CompatibleWithChatAssistant`** — flag for chat assistant
|
||||
compatibility.
|
||||
|
||||
### Deprecated
|
||||
|
||||
- **`Registration.TaskQueue`** — use `DeploymentID` instead. Will be
|
||||
removed in a future release.
|
||||
|
||||
### Removed (breaking)
|
||||
|
||||
- **`GetWorkflowWorkerInfo`** — the `/v1/workflows/workers/whoami` endpoint
|
||||
was removed upstream.
|
||||
- **`workflow.WorkerInfo`** — type no longer exists in the API.
|
||||
|
||||
## v1.2.1 — 2026-04-03
|
||||
|
||||
Move module path to `github.com/VikingOwl91/mistral-go-sdk` for public
|
||||
discoverability on pkg.go.dev.
|
||||
|
||||
### Changed
|
||||
|
||||
- Module path changed from `somegit.dev/vikingowl/mistral-go-sdk` to
|
||||
`github.com/VikingOwl91/mistral-go-sdk`.
|
||||
|
||||
### Fixed
|
||||
|
||||
- `TestChatCompleteStream_WithToolCalls` fixture now includes `finish_reason`
|
||||
and `usage` to match real Mistral API responses.
|
||||
|
||||
## v1.2.0 — 2026-04-02
|
||||
|
||||
Upstream sync with Python SDK v2.2.0. Adds Workflows API and DeleteBatchJob.
|
||||
|
||||
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
|
||||
## Project
|
||||
|
||||
Idiomatic Go SDK for the Mistral AI API. Module path: `somegit.dev/vikingowl/mistral-go-sdk`. Requires Go 1.26+. Zero external dependencies (stdlib only). Tracks the upstream [Mistral Python SDK](https://github.com/mistralai/client-python) as reference for API surface and type definitions.
|
||||
Idiomatic Go SDK for the Mistral AI API. Module path: `github.com/VikingOwl91/mistral-go-sdk`. Requires Go 1.26+. Zero external dependencies (stdlib only). Tracks the upstream [Mistral Python SDK](https://github.com/mistralai/client-python) as reference for API surface and type definitions.
|
||||
|
||||
## Repository layout
|
||||
|
||||
|
||||
17
README.md
17
README.md
@@ -3,7 +3,7 @@
|
||||
The most complete Go client for the [Mistral AI API](https://docs.mistral.ai/).
|
||||
|
||||
<!-- Badges -->
|
||||
[](https://pkg.go.dev/somegit.dev/vikingowl/mistral-go-sdk)
|
||||
[](https://pkg.go.dev/github.com/VikingOwl91/mistral-go-sdk)
|
||||

|
||||

|
||||
|
||||
@@ -11,7 +11,7 @@ The most complete Go client for the [Mistral AI API](https://docs.mistral.ai/).
|
||||
|
||||
**Zero dependencies.** The entire SDK — including tests — uses only the Go standard library. No `go.sum`, no transitive dependency tree to audit, no version conflicts, no supply chain risk.
|
||||
|
||||
**Full API coverage.** 166 methods across every Mistral endpoint — including Workflows, Connectors, Audio Speech/Voices, Conversations, Agents CRUD, Libraries, OCR, Observability, Fine-tuning, and Batch Jobs. No other Go SDK covers Workflows, Conversations, Connectors, or Observability.
|
||||
**Full API coverage.** 165 methods across every Mistral endpoint — including Workflows, Connectors, Audio Speech/Voices, Conversations, Agents CRUD, Libraries, OCR, Observability, Fine-tuning, and Batch Jobs. No other Go SDK covers Workflows, Conversations, Connectors, or Observability.
|
||||
|
||||
**Typed streaming.** A generic pull-based `Stream[T]` iterator — no channels, no goroutines, no leaks. Just `Next()` / `Current()` / `Err()` / `Close()`.
|
||||
|
||||
@@ -24,7 +24,7 @@ The most complete Go client for the [Mistral AI API](https://docs.mistral.ai/).
|
||||
## Install
|
||||
|
||||
```sh
|
||||
go get somegit.dev/vikingowl/mistral-go-sdk
|
||||
go get github.com/VikingOwl91/mistral-go-sdk
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
@@ -39,8 +39,8 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
mistral "somegit.dev/vikingowl/mistral-go-sdk"
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/chat"
|
||||
mistral "github.com/VikingOwl91/mistral-go-sdk"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/chat"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -112,7 +112,7 @@ resp, err := client.ChatComplete(ctx, &chat.CompletionRequest{
|
||||
### Conversations
|
||||
|
||||
```go
|
||||
import "somegit.dev/vikingowl/mistral-go-sdk/conversation"
|
||||
import "github.com/VikingOwl91/mistral-go-sdk/conversation"
|
||||
|
||||
resp, err := client.StartConversation(ctx, &conversation.StartRequest{
|
||||
AgentID: "ag-your-agent-id",
|
||||
@@ -132,7 +132,7 @@ for stream.Next() {
|
||||
|
||||
## API Coverage
|
||||
|
||||
166 public methods on `Client`, grouped by domain:
|
||||
165 public methods on `Client`, grouped by domain:
|
||||
|
||||
| Domain | Methods |
|
||||
|--------|---------|
|
||||
@@ -167,7 +167,6 @@ for stream.Next() {
|
||||
| **Workflows (metrics)** | `GetWorkflowMetrics` |
|
||||
| **Workflows (runs)** | `ListWorkflowRuns`, `GetWorkflowRun`, `GetWorkflowRunHistory` |
|
||||
| **Workflows (schedules)** | `ListWorkflowSchedules`, `ScheduleWorkflow`, `UnscheduleWorkflow` |
|
||||
| **Workflows (workers)** | `GetWorkflowWorkerInfo` |
|
||||
|
||||
## Comparison
|
||||
|
||||
@@ -241,6 +240,8 @@ as its upstream reference for API surface and type definitions.
|
||||
|
||||
| SDK Version | Upstream Python SDK |
|
||||
|-------------|---------------------|
|
||||
| v1.3.0 | v2.3.0 |
|
||||
| v1.2.1 | v2.2.0 |
|
||||
| v1.2.0 | v2.2.0 |
|
||||
| v1.1.0 | v2.1.3 |
|
||||
| v1.0.0 | v2.0.4 |
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/chat"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/chat"
|
||||
)
|
||||
|
||||
// AgentTool is a sealed interface for agent tool types.
|
||||
|
||||
@@ -3,7 +3,7 @@ package agents
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/chat"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/chat"
|
||||
)
|
||||
|
||||
// CompletionRequest represents an agents completion request.
|
||||
|
||||
@@ -3,8 +3,8 @@ package mistral
|
||||
import (
|
||||
"context"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/agents"
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/chat"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/agents"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/chat"
|
||||
)
|
||||
|
||||
// AgentsComplete sends an agents completion request.
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/agents"
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/chat"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/agents"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/chat"
|
||||
)
|
||||
|
||||
func TestAgentsComplete_Success(t *testing.T) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/agents"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/agents"
|
||||
)
|
||||
|
||||
// CreateAgent creates a new agent.
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/agents"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/agents"
|
||||
)
|
||||
|
||||
func TestCreateAgent_Success(t *testing.T) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/audio"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/audio"
|
||||
)
|
||||
|
||||
// Transcribe sends an audio file for transcription.
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/audio"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/audio"
|
||||
)
|
||||
|
||||
func TestSpeech_Success(t *testing.T) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/audio"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/audio"
|
||||
)
|
||||
|
||||
func TestTranscribe_WithFileURL(t *testing.T) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/batch"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/batch"
|
||||
)
|
||||
|
||||
// CreateBatchJob creates a new batch inference job.
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/batch"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/batch"
|
||||
)
|
||||
|
||||
func TestCreateBatchJob_Success(t *testing.T) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package mistral
|
||||
import (
|
||||
"context"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/chat"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/chat"
|
||||
)
|
||||
|
||||
// ChatComplete sends a chat completion request and returns the full response.
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/chat"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/chat"
|
||||
)
|
||||
|
||||
func TestChatComplete_Success(t *testing.T) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/chat"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/chat"
|
||||
)
|
||||
|
||||
func TestChatCompleteStream_Success(t *testing.T) {
|
||||
@@ -165,6 +165,7 @@ func TestChatCompleteStream_WithToolCalls(t *testing.T) {
|
||||
w.Header().Set("Content-Type", "text/event-stream")
|
||||
flusher, _ := w.(http.Flusher)
|
||||
|
||||
toolCalls := chat.FinishReasonToolCalls
|
||||
chunk := chat.CompletionChunk{
|
||||
ID: "c",
|
||||
Model: "m",
|
||||
@@ -177,7 +178,9 @@ func TestChatCompleteStream_WithToolCalls(t *testing.T) {
|
||||
Function: chat.FunctionCall{Name: "get_weather", Arguments: `{"city":"Paris"}`},
|
||||
}},
|
||||
},
|
||||
FinishReason: &toolCalls,
|
||||
}},
|
||||
Usage: &chat.UsageInfo{PromptTokens: 10, CompletionTokens: 5, TotalTokens: 15},
|
||||
}
|
||||
data, _ := json.Marshal(chunk)
|
||||
fmt.Fprintf(w, "data: %s\n\n", data)
|
||||
@@ -199,10 +202,17 @@ func TestChatCompleteStream_WithToolCalls(t *testing.T) {
|
||||
if !stream.Next() {
|
||||
t.Fatalf("expected chunk, err: %v", stream.Err())
|
||||
}
|
||||
tc := stream.Current().Choices[0].Delta.ToolCalls
|
||||
cur := stream.Current()
|
||||
tc := cur.Choices[0].Delta.ToolCalls
|
||||
if len(tc) != 1 || tc[0].Function.Name != "get_weather" {
|
||||
t.Errorf("got tool calls %+v", tc)
|
||||
}
|
||||
if cur.Choices[0].FinishReason == nil || *cur.Choices[0].FinishReason != chat.FinishReasonToolCalls {
|
||||
t.Errorf("expected finish_reason tool_calls, got %v", cur.Choices[0].FinishReason)
|
||||
}
|
||||
if cur.Usage == nil || cur.Usage.TotalTokens != 15 {
|
||||
t.Errorf("expected usage with total_tokens=15, got %+v", cur.Usage)
|
||||
}
|
||||
}
|
||||
|
||||
func TestChatCompleteStream_APIError(t *testing.T) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package classification
|
||||
|
||||
import "somegit.dev/vikingowl/mistral-go-sdk/chat"
|
||||
import "github.com/VikingOwl91/mistral-go-sdk/chat"
|
||||
|
||||
// Request represents a text classification request (/v1/classifications).
|
||||
type Request struct {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/connector"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/connector"
|
||||
)
|
||||
|
||||
// CreateConnector registers a new MCP connector.
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/connector"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/connector"
|
||||
)
|
||||
|
||||
func TestCreateConnector_Success(t *testing.T) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/chat"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/chat"
|
||||
)
|
||||
|
||||
// HandoffExecution controls tool call execution.
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/chat"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/chat"
|
||||
)
|
||||
|
||||
// Entry is a sealed interface for conversation history entries.
|
||||
|
||||
@@ -3,7 +3,7 @@ package conversation
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/chat"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/chat"
|
||||
)
|
||||
|
||||
// StartRequest starts a new conversation.
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/conversation"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/conversation"
|
||||
)
|
||||
|
||||
// StartConversation creates and starts a new conversation.
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/conversation"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/conversation"
|
||||
)
|
||||
|
||||
func TestStartConversation_Success(t *testing.T) {
|
||||
|
||||
@@ -1144,7 +1144,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
func TestListWorkflows_Success(t *testing.T) {
|
||||
@@ -1387,7 +1387,7 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
// ListWorkflows lists workflows.
|
||||
@@ -1616,7 +1616,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
func TestGetWorkflowExecution_Success(t *testing.T) {
|
||||
@@ -1849,7 +1849,7 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
// GetWorkflowExecution retrieves a workflow execution by ID.
|
||||
@@ -2099,7 +2099,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
func TestListWorkflowEvents_Success(t *testing.T) {
|
||||
@@ -2241,7 +2241,7 @@ func TestGetWorkflowMetrics_Success(t *testing.T) {
|
||||
}
|
||||
```
|
||||
|
||||
Add `"somegit.dev/vikingowl/mistral-go-sdk/workflow"` import to `workflows_metrics_test.go`.
|
||||
Add `"github.com/VikingOwl91/mistral-go-sdk/workflow"` import to `workflows_metrics_test.go`.
|
||||
|
||||
- [ ] **Step 2: Run tests to verify they fail**
|
||||
|
||||
@@ -2262,7 +2262,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
// StreamWorkflowEvents streams workflow events via SSE.
|
||||
@@ -2365,7 +2365,7 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
// ListWorkflowDeployments lists workflow deployments.
|
||||
@@ -2410,7 +2410,7 @@ import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
// GetWorkflowMetrics retrieves performance metrics for a workflow.
|
||||
@@ -2534,7 +2534,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
func TestScheduleWorkflow_Success(t *testing.T) {
|
||||
@@ -2675,7 +2675,7 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
// ListWorkflowRuns lists workflow runs.
|
||||
@@ -2737,7 +2737,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
// ListWorkflowSchedules lists workflow schedules.
|
||||
@@ -2780,7 +2780,7 @@ package mistral
|
||||
import (
|
||||
"context"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
// GetWorkflowWorkerInfo retrieves information about the current worker.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package embedding
|
||||
|
||||
import "somegit.dev/vikingowl/mistral-go-sdk/chat"
|
||||
import "github.com/VikingOwl91/mistral-go-sdk/chat"
|
||||
|
||||
// Dtype specifies the data type of output embeddings.
|
||||
type Dtype string
|
||||
|
||||
@@ -3,7 +3,7 @@ package mistral
|
||||
import (
|
||||
"context"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/embedding"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/embedding"
|
||||
)
|
||||
|
||||
// CreateEmbeddings sends an embedding request and returns the response.
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/embedding"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/embedding"
|
||||
)
|
||||
|
||||
func TestCreateEmbeddings_Success(t *testing.T) {
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
mistral "somegit.dev/vikingowl/mistral-go-sdk"
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/chat"
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/embedding"
|
||||
mistral "github.com/VikingOwl91/mistral-go-sdk"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/chat"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/embedding"
|
||||
)
|
||||
|
||||
func ExampleNewClient() {
|
||||
|
||||
2
files.go
2
files.go
@@ -8,7 +8,7 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/file"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/file"
|
||||
)
|
||||
|
||||
// UploadFile uploads a file for use with fine-tuning, batch, or OCR.
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/file"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/file"
|
||||
)
|
||||
|
||||
func TestUploadFile_Success(t *testing.T) {
|
||||
|
||||
@@ -3,8 +3,8 @@ package mistral
|
||||
import (
|
||||
"context"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/chat"
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/fim"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/chat"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/fim"
|
||||
)
|
||||
|
||||
// FIMComplete sends a Fill-In-the-Middle completion request.
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/chat"
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/fim"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/chat"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/fim"
|
||||
)
|
||||
|
||||
func TestFIMComplete_Success(t *testing.T) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/finetune"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/finetune"
|
||||
)
|
||||
|
||||
// CreateFineTuningJob creates a new fine-tuning job.
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/finetune"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/finetune"
|
||||
)
|
||||
|
||||
func TestCreateFineTuningJob_Success(t *testing.T) {
|
||||
|
||||
2
go.mod
2
go.mod
@@ -1,3 +1,3 @@
|
||||
module somegit.dev/vikingowl/mistral-go-sdk
|
||||
module github.com/VikingOwl91/mistral-go-sdk
|
||||
|
||||
go 1.26
|
||||
|
||||
@@ -8,8 +8,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/chat"
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/embedding"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/chat"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/embedding"
|
||||
)
|
||||
|
||||
func integrationClient(t *testing.T) *Client {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/library"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/library"
|
||||
)
|
||||
|
||||
// CreateLibrary creates a new document library.
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/library"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/library"
|
||||
)
|
||||
|
||||
func newLibraryJSON() map[string]any {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
// Version is the SDK version string.
|
||||
const Version = "1.2.0"
|
||||
const Version = "1.3.0"
|
||||
|
||||
const (
|
||||
defaultBaseURL = "https://api.mistral.ai"
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"net/url"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/model"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/model"
|
||||
)
|
||||
|
||||
// ListModels returns a list of available models.
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/model"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/model"
|
||||
)
|
||||
|
||||
func TestListModels_Success(t *testing.T) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package moderation
|
||||
|
||||
import "somegit.dev/vikingowl/mistral-go-sdk/chat"
|
||||
import "github.com/VikingOwl91/mistral-go-sdk/chat"
|
||||
|
||||
// Request represents a text moderation request (/v1/moderations).
|
||||
type Request struct {
|
||||
|
||||
@@ -3,8 +3,8 @@ package mistral
|
||||
import (
|
||||
"context"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/classification"
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/moderation"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/classification"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/moderation"
|
||||
)
|
||||
|
||||
// Moderate sends a text moderation request.
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/classification"
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/moderation"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/classification"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/moderation"
|
||||
)
|
||||
|
||||
func TestModerate_Success(t *testing.T) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/observability"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/observability"
|
||||
)
|
||||
|
||||
// CreateCampaign creates a new observability campaign.
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/observability"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/observability"
|
||||
)
|
||||
|
||||
func TestCreateCampaign_Success(t *testing.T) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/observability"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/observability"
|
||||
)
|
||||
|
||||
// CreateDataset creates a new observability dataset.
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/observability"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/observability"
|
||||
)
|
||||
|
||||
func datasetJSON() map[string]any {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/observability"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/observability"
|
||||
)
|
||||
|
||||
// SearchChatCompletionEvents searches for chat completion events.
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/observability"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/observability"
|
||||
)
|
||||
|
||||
func TestSearchChatCompletionEvents_Success(t *testing.T) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/observability"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/observability"
|
||||
)
|
||||
|
||||
// CreateJudge creates a new observability judge.
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/observability"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/observability"
|
||||
)
|
||||
|
||||
func judgeJSON() map[string]any {
|
||||
|
||||
@@ -3,7 +3,7 @@ package mistral
|
||||
import (
|
||||
"context"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/ocr"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/ocr"
|
||||
)
|
||||
|
||||
// OCR performs optical character recognition on a document.
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/ocr"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/ocr"
|
||||
)
|
||||
|
||||
func TestOCR_Success(t *testing.T) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/chat"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/chat"
|
||||
)
|
||||
|
||||
func TestRetry_429ThenSuccess(t *testing.T) {
|
||||
|
||||
36
workflow/definition.go
Normal file
36
workflow/definition.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package workflow
|
||||
|
||||
// CodeDefinition describes a workflow's code-level interface: its input/output
|
||||
// schemas, signal/query/update handlers, and execution constraints.
|
||||
type CodeDefinition struct {
|
||||
InputSchema map[string]any `json:"input_schema"`
|
||||
OutputSchema map[string]any `json:"output_schema,omitempty"`
|
||||
Signals []SignalDefinition `json:"signals,omitempty"`
|
||||
Queries []QueryDefinition `json:"queries,omitempty"`
|
||||
Updates []UpdateDefinition `json:"updates,omitempty"`
|
||||
EnforceDeterminism bool `json:"enforce_determinism,omitempty"`
|
||||
ExecutionTimeout *float64 `json:"execution_timeout,omitempty"`
|
||||
}
|
||||
|
||||
// SignalDefinition describes a signal handler on a workflow.
|
||||
type SignalDefinition struct {
|
||||
Name string `json:"name"`
|
||||
InputSchema map[string]any `json:"input_schema"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
}
|
||||
|
||||
// QueryDefinition describes a query handler on a workflow.
|
||||
type QueryDefinition struct {
|
||||
Name string `json:"name"`
|
||||
InputSchema map[string]any `json:"input_schema"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
OutputSchema map[string]any `json:"output_schema,omitempty"`
|
||||
}
|
||||
|
||||
// UpdateDefinition describes an update handler on a workflow.
|
||||
type UpdateDefinition struct {
|
||||
Name string `json:"name"`
|
||||
InputSchema map[string]any `json:"input_schema"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
OutputSchema map[string]any `json:"output_schema,omitempty"`
|
||||
}
|
||||
166
workflow/definition_test.go
Normal file
166
workflow/definition_test.go
Normal file
@@ -0,0 +1,166 @@
|
||||
package workflow
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCodeDefinition_RoundTrip(t *testing.T) {
|
||||
raw := `{
|
||||
"input_schema": {"type": "object", "properties": {"prompt": {"type": "string"}}},
|
||||
"output_schema": {"type": "object", "properties": {"result": {"type": "string"}}},
|
||||
"signals": [
|
||||
{"name": "cancel", "input_schema": {"type": "object"}, "description": "Cancel the workflow"}
|
||||
],
|
||||
"queries": [
|
||||
{"name": "status", "input_schema": {"type": "object"}, "description": "Get status", "output_schema": {"type": "string"}}
|
||||
],
|
||||
"updates": [
|
||||
{"name": "set_priority", "input_schema": {"type": "object", "properties": {"level": {"type": "integer"}}}, "description": "Set priority", "output_schema": null}
|
||||
],
|
||||
"enforce_determinism": true,
|
||||
"execution_timeout": 3600.5
|
||||
}`
|
||||
|
||||
var def CodeDefinition
|
||||
if err := json.Unmarshal([]byte(raw), &def); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if def.InputSchema == nil {
|
||||
t.Fatal("InputSchema is nil")
|
||||
}
|
||||
if def.OutputSchema == nil {
|
||||
t.Fatal("OutputSchema is nil")
|
||||
}
|
||||
if len(def.Signals) != 1 {
|
||||
t.Fatalf("expected 1 signal, got %d", len(def.Signals))
|
||||
}
|
||||
if def.Signals[0].Name != "cancel" {
|
||||
t.Errorf("signal name = %q, want cancel", def.Signals[0].Name)
|
||||
}
|
||||
if def.Signals[0].Description == nil || *def.Signals[0].Description != "Cancel the workflow" {
|
||||
t.Errorf("signal description wrong")
|
||||
}
|
||||
if len(def.Queries) != 1 {
|
||||
t.Fatalf("expected 1 query, got %d", len(def.Queries))
|
||||
}
|
||||
if def.Queries[0].Name != "status" {
|
||||
t.Errorf("query name = %q, want status", def.Queries[0].Name)
|
||||
}
|
||||
if def.Queries[0].OutputSchema == nil {
|
||||
t.Error("query OutputSchema is nil, expected non-nil")
|
||||
}
|
||||
if len(def.Updates) != 1 {
|
||||
t.Fatalf("expected 1 update, got %d", len(def.Updates))
|
||||
}
|
||||
if def.Updates[0].Name != "set_priority" {
|
||||
t.Errorf("update name = %q, want set_priority", def.Updates[0].Name)
|
||||
}
|
||||
if def.EnforceDeterminism != true {
|
||||
t.Error("EnforceDeterminism should be true")
|
||||
}
|
||||
if def.ExecutionTimeout == nil || *def.ExecutionTimeout != 3600.5 {
|
||||
t.Errorf("ExecutionTimeout = %v, want 3600.5", def.ExecutionTimeout)
|
||||
}
|
||||
|
||||
// Re-marshal and verify round-trip
|
||||
out, err := json.Marshal(def)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var def2 CodeDefinition
|
||||
if err := json.Unmarshal(out, &def2); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(def2.Signals) != 1 || def2.Signals[0].Name != "cancel" {
|
||||
t.Error("round-trip failed for signals")
|
||||
}
|
||||
if def2.EnforceDeterminism != true {
|
||||
t.Error("round-trip failed for enforce_determinism")
|
||||
}
|
||||
}
|
||||
|
||||
func TestCodeDefinition_MinimalFields(t *testing.T) {
|
||||
raw := `{"input_schema": {"type": "object"}}`
|
||||
|
||||
var def CodeDefinition
|
||||
if err := json.Unmarshal([]byte(raw), &def); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if def.InputSchema == nil {
|
||||
t.Fatal("InputSchema is nil")
|
||||
}
|
||||
if def.OutputSchema != nil {
|
||||
t.Errorf("OutputSchema should be nil, got %v", def.OutputSchema)
|
||||
}
|
||||
if def.Signals != nil {
|
||||
t.Errorf("Signals should be nil, got %v", def.Signals)
|
||||
}
|
||||
if def.EnforceDeterminism != false {
|
||||
t.Error("EnforceDeterminism should default to false")
|
||||
}
|
||||
if def.ExecutionTimeout != nil {
|
||||
t.Errorf("ExecutionTimeout should be nil, got %v", def.ExecutionTimeout)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegistration_NewFields(t *testing.T) {
|
||||
raw := `{
|
||||
"id": "reg-1",
|
||||
"workflow_id": "wf-1",
|
||||
"task_queue": "legacy-queue",
|
||||
"deployment_id": "dep-abc",
|
||||
"compatible_with_chat_assistant": true,
|
||||
"definition": {
|
||||
"input_schema": {"type": "object"},
|
||||
"enforce_determinism": false
|
||||
},
|
||||
"created_at": "2026-04-01T00:00:00Z",
|
||||
"updated_at": "2026-04-02T00:00:00Z"
|
||||
}`
|
||||
|
||||
var reg Registration
|
||||
if err := json.Unmarshal([]byte(raw), ®); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if reg.ID != "reg-1" {
|
||||
t.Errorf("ID = %q", reg.ID)
|
||||
}
|
||||
if reg.DeploymentID == nil || *reg.DeploymentID != "dep-abc" {
|
||||
t.Errorf("DeploymentID = %v, want dep-abc", reg.DeploymentID)
|
||||
}
|
||||
if reg.CompatibleWithChatAssistant != true {
|
||||
t.Error("CompatibleWithChatAssistant should be true")
|
||||
}
|
||||
if reg.Definition == nil {
|
||||
t.Fatal("Definition is nil")
|
||||
}
|
||||
if reg.Definition.InputSchema == nil {
|
||||
t.Error("Definition.InputSchema is nil")
|
||||
}
|
||||
// TaskQueue still works for backward compat
|
||||
if reg.TaskQueue != "legacy-queue" {
|
||||
t.Errorf("TaskQueue = %q, want legacy-queue", reg.TaskQueue)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRegistration_NullDeploymentID(t *testing.T) {
|
||||
raw := `{
|
||||
"id": "reg-2",
|
||||
"workflow_id": "wf-2",
|
||||
"task_queue": "q",
|
||||
"definition": {"input_schema": {"type": "object"}}
|
||||
}`
|
||||
|
||||
var reg Registration
|
||||
if err := json.Unmarshal([]byte(raw), ®); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if reg.DeploymentID != nil {
|
||||
t.Errorf("DeploymentID should be nil, got %v", reg.DeploymentID)
|
||||
}
|
||||
if reg.CompatibleWithChatAssistant != false {
|
||||
t.Error("CompatibleWithChatAssistant should default to false")
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,12 @@ package workflow
|
||||
|
||||
// Registration represents a workflow registration.
|
||||
type Registration struct {
|
||||
ID string `json:"id"`
|
||||
WorkflowID string `json:"workflow_id"`
|
||||
ID string `json:"id"`
|
||||
WorkflowID string `json:"workflow_id"`
|
||||
Definition *CodeDefinition `json:"definition,omitempty"`
|
||||
DeploymentID *string `json:"deployment_id,omitempty"`
|
||||
CompatibleWithChatAssistant bool `json:"compatible_with_chat_assistant,omitempty"`
|
||||
// Deprecated: use DeploymentID instead. Will be removed in a future release.
|
||||
TaskQueue string `json:"task_queue"`
|
||||
Workflow *Workflow `json:"workflow,omitempty"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
@@ -35,10 +39,3 @@ type RegistrationGetParams struct {
|
||||
WithWorkflow *bool
|
||||
IncludeShared *bool
|
||||
}
|
||||
|
||||
// WorkerInfo holds information about the current worker.
|
||||
type WorkerInfo struct {
|
||||
SchedulerURL string `json:"scheduler_url"`
|
||||
Namespace string `json:"namespace"`
|
||||
TLS bool `json:"tls"`
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
// ListWorkflows lists workflows.
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
// ListWorkflowDeployments lists workflow deployments.
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
// StreamWorkflowEvents streams workflow events via SSE.
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
func TestListWorkflowEvents_Success(t *testing.T) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
// GetWorkflowExecution retrieves a workflow execution by ID.
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
func TestGetWorkflowExecution_Success(t *testing.T) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
// GetWorkflowMetrics retrieves performance metrics for a workflow.
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
func TestGetWorkflowMetrics_Success(t *testing.T) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
// ListWorkflowRuns lists workflow runs.
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
// ListWorkflowSchedules lists workflow schedules.
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
func TestScheduleWorkflow_Success(t *testing.T) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
"github.com/VikingOwl91/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
func TestListWorkflows_Success(t *testing.T) {
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package mistral
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"somegit.dev/vikingowl/mistral-go-sdk/workflow"
|
||||
)
|
||||
|
||||
// GetWorkflowWorkerInfo retrieves information about the current worker.
|
||||
func (c *Client) GetWorkflowWorkerInfo(ctx context.Context) (*workflow.WorkerInfo, error) {
|
||||
var resp workflow.WorkerInfo
|
||||
if err := c.doJSON(ctx, "GET", "/v1/workflows/workers/whoami", nil, &resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package mistral
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetWorkflowWorkerInfo_Success(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/v1/workflows/workers/whoami" {
|
||||
t.Errorf("got path %s", r.URL.Path)
|
||||
}
|
||||
json.NewEncoder(w).Encode(map[string]any{
|
||||
"scheduler_url": "https://scheduler.mistral.ai",
|
||||
"namespace": "default",
|
||||
"tls": true,
|
||||
})
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
client := NewClient("key", WithBaseURL(server.URL))
|
||||
info, err := client.GetWorkflowWorkerInfo(context.Background())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if info.Namespace != "default" {
|
||||
t.Errorf("got namespace %q", info.Namespace)
|
||||
}
|
||||
if !info.TLS {
|
||||
t.Error("expected tls=true")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user