MCPcopy Index your code
hub / github.com/coder/coder / advisorToolCapturingQuestion

Function advisorToolCapturingQuestion

coderd/x/chatd/chatadvisor/tool_test.go:412–439  ·  view source on GitHub ↗
(t *testing.T, capturedQuestion *string)

Source from the content-addressed store, hash-verified

410}
411
412func advisorToolCapturingQuestion(t *testing.T, capturedQuestion *string) fantasy.AgentTool {
413 t.Helper()
414
415 runtime, err := chatadvisor.NewRuntime(chatadvisor.RuntimeConfig{
416 Model: &chattest.FakeModel{
417 ProviderName: "test-provider",
418 ModelName: "test-model",
419 StreamFn: func(_ context.Context, call fantasy.Call) (fantasy.StreamResponse, error) {
420 require.NotEmpty(t, call.Prompt)
421 *capturedQuestion = singleText(t, call.Prompt[len(call.Prompt)-1])
422 return streamFromParts([]fantasy.StreamPart{
423 {Type: fantasy.StreamPartTypeTextStart, ID: "text-1"},
424 {Type: fantasy.StreamPartTypeTextDelta, ID: "text-1", Delta: "captured advice"},
425 {Type: fantasy.StreamPartTypeTextEnd, ID: "text-1"},
426 {Type: fantasy.StreamPartTypeFinish, FinishReason: fantasy.FinishReasonStop},
427 }), nil
428 },
429 },
430 MaxUsesPerRun: 1,
431 MaxOutputTokens: 64,
432 })
433 require.NoError(t, err)
434
435 return chatadvisor.Tool(chatadvisor.ToolOptions{
436 Runtime: runtime,
437 GetConversationSnapshot: func() []fantasy.Message { return nil },
438 })
439}
440
441func runAdvisorTool(
442 t *testing.T,

Calls 6

NewRuntimeFunction · 0.92
ToolFunction · 0.92
singleTextFunction · 0.85
NotEmptyMethod · 0.80
streamFromPartsFunction · 0.70
HelperMethod · 0.65

Tested by

no test coverage detected