MCPcopy Index your code
hub / github.com/dagger/dagger / startInteractivePromptMode

Function startInteractivePromptMode

cmd/dagger/functions.go:974–1010  ·  view source on GitHub ↗

startInteractivePromptMode starts the interactive shell with the returned LLM assigned as $agent

(ctx context.Context, dag *dagger.Client, response any)

Source from the content-addressed store, hash-verified

972
973// startInteractivePromptMode starts the interactive shell with the returned LLM assigned as $agent
974func startInteractivePromptMode(ctx context.Context, dag *dagger.Client, response any) error {
975 // Extract the LLM ID from the response
976 var llmID string
977 switch v := response.(type) {
978 case string:
979 llmID = v
980 case map[string]any:
981 if id, ok := v["id"].(string); ok {
982 llmID = id
983 } else {
984 return fmt.Errorf("startInteractivePromptMode: no ID found in LLM object: %+v", v)
985 }
986 default:
987 return fmt.Errorf("startInteractivePromptMode: unexpected response type for LLM: %T", v)
988 }
989
990 // Set up the shell handler with prompt mode
991 handler := newShellCallHandler(dag, Frontend)
992 handler.mode = modePrompt
993
994 // Initialize the handler
995 if err := handler.Initialize(ctx); err != nil {
996 return err
997 }
998
999 // Load the LLM from the ID and assign it as $agent
1000 llm := dagger.Ref[*dagger.LLM](dag, dagger.ID(llmID))
1001 if _, err := handler.llm(ctx); err != nil { // init llmSession
1002 return err
1003 }
1004 if err := handler.llmSession.updateLLMAndAgentVar(llm); err != nil {
1005 return err
1006 }
1007
1008 // Start interactive mode
1009 return handler.runInteractive(ctx)
1010}
1011
1012func printID(w io.Writer, response any, typeDef *modTypeDef) error {
1013 switch {

Callers 1

handleResponseFunction · 0.85

Calls 7

newShellCallHandlerFunction · 0.85
InitializeMethod · 0.80
updateLLMAndAgentVarMethod · 0.80
runInteractiveMethod · 0.80
IDMethod · 0.65
RefMethod · 0.45
llmMethod · 0.45

Tested by

no test coverage detected