Home / Market / go-tinker

go-tinker

Unofficial Go client for the Thinking Machines Tinker API, generated with oapi-codegen. `tinker.NewClientWithResponses(baseURL, auth)` from `github.com/psyb0t/go-tinker` gives typed methods for every endpoint of the Tinker training API (create and unload LoRA models, forward and forward-backward passes, optimizer steps, sampling, saving and loading weights, retrieving futures, server capabilities, health). Auth is an `X-API-Key` header set in a request editor. Use when Go code needs to call the

skill★ 00 dlclawhubMIT-0Install in CosmosUpstream Source

Documentation & Preview

go-tinker: setup and reference

Requirements

Install

go get github.com/psyb0t/go-tinker

The package name is tinker:

import "github.com/psyb0t/go-tinker"

Client

Endpoints

| Method | HTTP | Request body | JSON200 | |---|---|---|---| | CreateModelWithResponse | POST /api/v1/create_model | CreateModelRequest | *UntypedAPIFuture | | UnloadModelWithResponse | POST /api/v1/unload_model | UnloadModelRequest | *UntypedAPIFuture | | ForwardWithResponse | POST /api/v1/forward | ForwardJSONRequestBody | *UntypedAPIFuture | | ForwardBackwardWithResponse | POST /api/v1/forward_backward | ForwardBackwardJSONRequestBody | *UntypedAPIFuture | | OptimStepWithResponse | POST /api/v1/optim_step | OptimStepRequest | *UntypedAPIFuture | | SaveWeightsWithResponse | POST /api/v1/save_weights | SaveWeightsRequest | *UntypedAPIFuture | | LoadWeightsWithResponse | POST /api/v1/load_weights | LoadWeightsRequest | *UntypedAPIFuture | | SaveWeightsForSamplerWithResponse | POST /api/v1/save_weights_for_sampler | SaveWeightsForSamplerRequest | *UntypedAPIFuture | | SampleWithResponse | POST /api/v1/sample | SampleRequest | *SampleResponse | | AsampleWithResponse | POST /api/v1/asample | SampleRequest | *UntypedAPIFuture | | RetrieveFutureWithResponse | POST /api/v1/retrieve_future | UntypedAPIFuture | union, see below | | GetInfoWithResponse | POST /api/v1/get_info | GetInfoRequest | *GetInfoResponse | | GetServerCapabilitiesWithResponse | GET /api/v1/get_server_capabilities | none | *GetServerCapabilitiesResponse | | ReceiveTelemetryWithResponse | POST /api/v1/telemetry | TelemetryBatch | none, JSON202 is *TelemetryResponse | | HealthCheckWithResponse | GET /api/v1/healthz | none | *HealthResponse |

ForwardJSONRequestBody and ForwardBackwardJSONRequestBody are inline schemas with the input and model_id; the other bodies are aliases of the named schema types.

Response wrappers end in HTTPResponse (CreateModelHTTPResponse), because the spec's schema names already end in Response. Each wrapper has Body []byte, HTTPResponse *http.Response, StatusCode() and one field per documented status.

Futures

  1. A work call returns UntypedAPIFuture{RequestId, ModelId}.
  2. Pass that value to RetrieveFutureWithResponse.
  3. JSON408 (TryAgainResponse) means the result is not ready. Call again later.
  4. JSON200 is a union. Decode it with the As... method for the call you made: AsCreateModelResponse, AsForwardBackwardOutput, AsOptimStepResponse, AsSaveWeightsResponse, AsLoadWeightsResponse, AsSaveWeightsForSamplerResponse, AsUnloadModelResponse and the others on RetrieveFuture200JSONResponseBody. The union holds raw JSON, so an As... call for the wrong kind can still succeed with empty fields. Decode with the method that matches the call that created the future.

Errors

Numbers

Every number in the spec is float64 in Go, including the ones the spec marks format: float.