2026-09-08 09:15:13 -07:00
|
|
|
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
|
2026-09-08 12:49:08 -07:00
|
|
|
err := workflow.ExecuteActivity(actCtx, "LLMInferenceActivity", actInput).Get(actCtx, &result)
|
2026-09-08 09:15:13 -07:00
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result.Response, nil
|
|
|
|
|
}
|