Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- func (_c Client) Demo(ctx context.Context, method string, relativeURL string, body any) (res *http.Response, err error)
- func (_c Client) DemoInit(ctx context.Context, relativeURL string, body any) (res *http.Response, err error)
- func (_c Client) DemoStatus(ctx context.Context, relativeURL string) (res *http.Response, err error)
- func (_c Client) Embed(ctx context.Context, text string) (vector []float64, err error)
- func (_c Client) ForHost(host string) Client
- func (_c Client) Similarity(ctx context.Context, a string, b string) (score float64, err error)
- func (_c Client) WithOptions(opts ...pub.Option) Client
- type EmbedIn
- type EmbedOut
- type EmbedResponse
- type MulticastClient
- func (_c MulticastClient) Demo(ctx context.Context, method string, relativeURL string, body any) iter.Seq[*pub.Response]
- func (_c MulticastClient) DemoInit(ctx context.Context, relativeURL string, body any) iter.Seq[*pub.Response]
- func (_c MulticastClient) DemoStatus(ctx context.Context, relativeURL string) iter.Seq[*pub.Response]
- func (_c MulticastClient) Embed(ctx context.Context, text string) iter.Seq[*EmbedResponse]
- func (_c MulticastClient) ForHost(host string) MulticastClient
- func (_c MulticastClient) Similarity(ctx context.Context, a string, b string) iter.Seq[*SimilarityResponse]
- func (_c MulticastClient) WithOptions(opts ...pub.Option) MulticastClient
- type SimilarityIn
- type SimilarityOut
- type SimilarityResponse
Constants ¶
const Description = `` /* 164-byte string literal not displayed */
Description is the human-readable summary of the microservice, surfaced in OpenAPI and discovery.
const Hostname = "embedder.example"
Hostname is the default hostname of the microservice.
const Name = "Embedder"
Name is the decorative PascalCase name of the microservice.
const Version = 2
Version is a generation counter bumped on each regeneration, not a semantic version.
Variables ¶
var Demo = define.Web{ Host: Hostname, Method: "ANY", Route: ":443/demo", }
Demo serves the interactive demo page for the embedder.
var DemoInit = define.Web{ Host: Hostname, Method: "POST", Route: ":443/demo/init", }
DemoInit kicks off Python venv allocation in the background. It is idempotent: a second call while initialization is pending or already ready returns the current status without restarting.
var DemoStatus = define.Web{ Host: Hostname, Method: "GET", Route: ":443/demo/status", }
DemoStatus is a long-poll endpoint reporting venv initialization status and tailed logs. The client passes its last-seen ETag via If-None-Match; the server snapshots the current status and logs, hashes them into an ETag, and:
- returns 200 with the new ETag and body if the snapshot differs;
- holds the connection (polling every 500ms) until the snapshot changes;
- returns 204 No Content when the request is within ~1s of its deadline without any change, so the client can immediately re-issue the request with the same ETag.
A fresh client (no If-None-Match) gets the current snapshot back on the first iteration.
var Embed = define.Function{ Host: Hostname, Method: "GET", Route: ":443/embed", Manual: true, Tags: []string{"python"}, In: EmbedIn{}, Out: EmbedOut{}, }
Embed returns the sentence-embedding vector for the input text.
var MaxWorkers = define.Config{ Value: int(0), Default: "2", Validation: "int [1,]", }
MaxWorkers caps how many calls into the Python venv may run concurrently.
var Similarity = define.Function{ Host: Hostname, Method: "GET", Route: ":443/similarity", Manual: true, Tags: []string{"python"}, In: SimilarityIn{}, Out: SimilarityOut{}, }
Similarity returns the cosine similarity between the embeddings of strings a and b.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a lightweight proxy for making unicast calls to the microservice.
func (Client) Demo ¶
func (_c Client) Demo(ctx context.Context, method string, relativeURL string, body any) (res *http.Response, err error)
Demo serves the interactive demo page for the embedder.
func (Client) DemoInit ¶
func (_c Client) DemoInit(ctx context.Context, relativeURL string, body any) (res *http.Response, err error)
DemoInit kicks off Python venv allocation in the background. It is idempotent: a second call while initialization is pending or already ready returns the current status without restarting.
func (Client) DemoStatus ¶
func (_c Client) DemoStatus(ctx context.Context, relativeURL string) (res *http.Response, err error)
DemoStatus is a long-poll endpoint reporting venv initialization status and tailed logs. The client passes its last-seen ETag via If-None-Match; the server snapshots the current status and logs, hashes them into an ETag, and:
- returns 200 with the new ETag and body if the snapshot differs;
- holds the connection (polling every 500ms) until the snapshot changes;
- returns 204 No Content when the request is within ~1s of its deadline without any change, so the client can immediately re-issue the request with the same ETag.
A fresh client (no If-None-Match) gets the current snapshot back on the first iteration.
func (Client) ForHost ¶
ForHost returns a copy of the client with a different hostname to be applied to requests.
func (Client) Similarity ¶
Similarity returns the cosine similarity between the embeddings of strings a and b.
type EmbedIn ¶
type EmbedIn struct {
Text string `json:"text,omitzero" jsonschema_description:"Text is the input string to embed"`
}
EmbedIn are the input arguments of Embed.
type EmbedOut ¶
type EmbedOut struct {
Vector []float64 `json:"vector,omitzero" jsonschema_description:"Vector is the embedding produced by the model"`
}
EmbedOut are the output arguments of Embed.
type EmbedResponse ¶
type EmbedResponse multicastResponse // MARKER: Embed
EmbedResponse packs the response of Embed.
func (*EmbedResponse) Get ¶
func (_res *EmbedResponse) Get() (vector []float64, err error)
Get unpacks the return arguments of Embed.
type MulticastClient ¶
type MulticastClient struct {
// contains filtered or unexported fields
}
MulticastClient is a lightweight proxy for making multicast calls to the microservice.
func NewMulticastClient ¶
func NewMulticastClient(caller service.Publisher) MulticastClient
NewMulticastClient creates a new multicast client proxy to the microservice.
func (MulticastClient) Demo ¶
func (_c MulticastClient) Demo(ctx context.Context, method string, relativeURL string, body any) iter.Seq[*pub.Response]
Demo serves the interactive demo page for the embedder.
func (MulticastClient) DemoInit ¶
func (_c MulticastClient) DemoInit(ctx context.Context, relativeURL string, body any) iter.Seq[*pub.Response]
DemoInit kicks off Python venv allocation in the background. It is idempotent: a second call while initialization is pending or already ready returns the current status without restarting.
func (MulticastClient) DemoStatus ¶
func (_c MulticastClient) DemoStatus(ctx context.Context, relativeURL string) iter.Seq[*pub.Response]
DemoStatus is a long-poll endpoint reporting venv initialization status and tailed logs. The client passes its last-seen ETag via If-None-Match; the server snapshots the current status and logs, hashes them into an ETag, and:
- returns 200 with the new ETag and body if the snapshot differs;
- holds the connection (polling every 500ms) until the snapshot changes;
- returns 204 No Content when the request is within ~1s of its deadline without any change, so the client can immediately re-issue the request with the same ETag.
A fresh client (no If-None-Match) gets the current snapshot back on the first iteration.
func (MulticastClient) Embed ¶
func (_c MulticastClient) Embed(ctx context.Context, text string) iter.Seq[*EmbedResponse]
Embed returns the sentence-embedding vector for the input text.
func (MulticastClient) ForHost ¶
func (_c MulticastClient) ForHost(host string) MulticastClient
ForHost returns a copy of the client with a different hostname to be applied to requests.
func (MulticastClient) Similarity ¶
func (_c MulticastClient) Similarity(ctx context.Context, a string, b string) iter.Seq[*SimilarityResponse]
Similarity returns the cosine similarity between the embeddings of strings a and b.
func (MulticastClient) WithOptions ¶
func (_c MulticastClient) WithOptions(opts ...pub.Option) MulticastClient
WithOptions returns a copy of the client with options to be applied to requests.
type SimilarityIn ¶
type SimilarityIn struct {
A string `json:"a,omitzero" jsonschema_description:"A is the first input string"`
B string `json:"b,omitzero" jsonschema_description:"B is the second input string"`
}
SimilarityIn are the input arguments of Similarity.
type SimilarityOut ¶
type SimilarityOut struct {
Score float64 `json:"score,omitzero" jsonschema_description:"Score is the cosine similarity in [-1.0, 1.0]"`
}
SimilarityOut are the output arguments of Similarity.
type SimilarityResponse ¶
type SimilarityResponse multicastResponse // MARKER: Similarity
SimilarityResponse packs the response of Similarity.
func (*SimilarityResponse) Get ¶
func (_res *SimilarityResponse) Get() (score float64, err error)
Get unpacks the return arguments of Similarity.