(feat) Temporal SDK client, worker mgmt, k8s deployments (#10)
CI / CI (push) Successful in 4m11s
CI / CI (push) Successful in 4m11s
## Changes - `internal/temporal/client.go` — Robust Temporal client with retry (exp backoff), TLS, health check - `internal/temporal/worker.go` — Worker creation, activity/workflow registration, lifecycle - `internal/temporal/context.go` — Timeout helpers - `k8s/worker-deployment.yaml` — 2-10 replica HPA, liveness/readiness probes, security context, pod anti-affinity - `k8s/workflow-runner-deployment.yaml` — Singleton runner with probes - `k8s/kustomization.yaml` — Updated resource list Co-authored-by: poimen <[email protected]>
This commit was merged in pull request #10.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package workflow
|
||||
|
||||
import (
|
||||
"time"
|
||||
"go.temporal.io/sdk/workflow"
|
||||
"github.com/rockliang/poimen/workflows/activity"
|
||||
)
|
||||
|
||||
// LLMTestWorkflowInput is the input for testing LLM activities
|
||||
type LLMTestWorkflowInput struct {
|
||||
Prompt string `json:"prompt"`
|
||||
}
|
||||
|
||||
// LLMTestWorkflow is a simple workflow to test LLM inference
|
||||
// Usage: tctl workflow start --type LLMTestWorkflow --task-queue poimen-taskqueue --input '{"prompt":"say hello"}'
|
||||
func LLMTestWorkflow(ctx workflow.Context, input LLMTestWorkflowInput) (string, error) {
|
||||
// Call the LLM inference activity
|
||||
opts := workflow.ActivityOptions{
|
||||
StartToCloseTimeout: 60 * time.Second,
|
||||
}
|
||||
actCtx := workflow.WithActivityOptions(ctx, opts)
|
||||
|
||||
actInput := activity.LLMInferenceInput{
|
||||
Model: "reasoning",
|
||||
UserPrompt: input.Prompt,
|
||||
}
|
||||
|
||||
var result activity.LLMInferenceOutput
|
||||
err := workflow.ExecuteActivity(actCtx, "LLMInferenceActivity", actInput).Get(actCtx, &result)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return result.Response, nil
|
||||
}
|
||||
Reference in New Issue
Block a user