@@ -87,7 +87,7 @@ func readMultilineInput(cmd *cobra.Command, scanner *bufio.Scanner) (string, err
8787}
8888
8989// generateInteractiveWithReadline provides an enhanced interactive mode with readline support
90- func generateInteractiveWithReadline (cmd * cobra.Command , desktopClient * desktop.Client , backend , model , apiKey string ) error {
90+ func generateInteractiveWithReadline (cmd * cobra.Command , desktopClient * desktop.Client , model string ) error {
9191 usage := func () {
9292 fmt .Fprintln (os .Stderr , "Available Commands:" )
9393 fmt .Fprintln (os .Stderr , " /bye Exit" )
@@ -122,7 +122,7 @@ func generateInteractiveWithReadline(cmd *cobra.Command, desktopClient *desktop.
122122 })
123123 if err != nil {
124124 // Fall back to basic input mode if readline initialization fails
125- return generateInteractiveBasic (cmd , desktopClient , backend , model , apiKey )
125+ return generateInteractiveBasic (cmd , desktopClient , model )
126126 }
127127
128128 // Disable history if the environment variable is set
@@ -221,7 +221,7 @@ func generateInteractiveWithReadline(cmd *cobra.Command, desktopClient *desktop.
221221 }
222222 }()
223223
224- err := chatWithMarkdownContext (chatCtx , cmd , desktopClient , backend , model , userInput , apiKey )
224+ err := chatWithMarkdownContext (chatCtx , cmd , desktopClient , model , userInput )
225225
226226 // Clean up signal handler
227227 signal .Stop (sigChan )
@@ -246,7 +246,7 @@ func generateInteractiveWithReadline(cmd *cobra.Command, desktopClient *desktop.
246246}
247247
248248// generateInteractiveBasic provides a basic interactive mode (fallback)
249- func generateInteractiveBasic (cmd * cobra.Command , desktopClient * desktop.Client , backend , model , apiKey string ) error {
249+ func generateInteractiveBasic (cmd * cobra.Command , desktopClient * desktop.Client , model string ) error {
250250 scanner := bufio .NewScanner (os .Stdin )
251251 for {
252252 userInput , err := readMultilineInput (cmd , scanner )
@@ -282,7 +282,7 @@ func generateInteractiveBasic(cmd *cobra.Command, desktopClient *desktop.Client,
282282 }
283283 }()
284284
285- err = chatWithMarkdownContext (chatCtx , cmd , desktopClient , backend , model , userInput , apiKey )
285+ err = chatWithMarkdownContext (chatCtx , cmd , desktopClient , model , userInput )
286286
287287 cancelChat ()
288288 signal .Stop (sigChan )
@@ -484,12 +484,12 @@ func renderMarkdown(content string) (string, error) {
484484}
485485
486486// chatWithMarkdown performs chat and streams the response with selective markdown rendering.
487- func chatWithMarkdown (cmd * cobra.Command , client * desktop.Client , backend , model , prompt , apiKey string ) error {
488- return chatWithMarkdownContext (cmd .Context (), cmd , client , backend , model , prompt , apiKey )
487+ func chatWithMarkdown (cmd * cobra.Command , client * desktop.Client , model , prompt string ) error {
488+ return chatWithMarkdownContext (cmd .Context (), cmd , client , model , prompt )
489489}
490490
491491// chatWithMarkdownContext performs chat with context support and streams the response with selective markdown rendering.
492- func chatWithMarkdownContext (ctx context.Context , cmd * cobra.Command , client * desktop.Client , backend , model , prompt , apiKey string ) error {
492+ func chatWithMarkdownContext (ctx context.Context , cmd * cobra.Command , client * desktop.Client , model , prompt string ) error {
493493 colorMode , _ := cmd .Flags ().GetString ("color" )
494494 useMarkdown := shouldUseMarkdown (colorMode )
495495 debug , _ := cmd .Flags ().GetBool ("debug" )
@@ -504,15 +504,15 @@ func chatWithMarkdownContext(ctx context.Context, cmd *cobra.Command, client *de
504504
505505 if ! useMarkdown {
506506 // Simple case: just stream as plain text
507- return client .ChatWithContext (ctx , backend , model , prompt , apiKey , imageURLs , func (content string ) {
507+ return client .ChatWithContext (ctx , model , prompt , imageURLs , func (content string ) {
508508 cmd .Print (content )
509509 }, false )
510510 }
511511
512512 // For markdown: use streaming buffer to render code blocks as they complete
513513 markdownBuffer := NewStreamingMarkdownBuffer ()
514514
515- err = client .ChatWithContext (ctx , backend , model , prompt , apiKey , imageURLs , func (content string ) {
515+ err = client .ChatWithContext (ctx , model , prompt , imageURLs , func (content string ) {
516516 // Use the streaming markdown buffer to intelligently render content
517517 rendered , err := markdownBuffer .AddContent (content , true )
518518 if err != nil {
@@ -539,7 +539,6 @@ func chatWithMarkdownContext(ctx context.Context, cmd *cobra.Command, client *de
539539
540540func newRunCmd () * cobra.Command {
541541 var debug bool
542- var backend string
543542 var ignoreRuntimeMemoryCheck bool
544543 var colorMode string
545544 var detach bool
@@ -557,19 +556,6 @@ func newRunCmd() *cobra.Command {
557556 }
558557 },
559558 RunE : func (cmd * cobra.Command , args []string ) error {
560- // Validate backend if specified
561- if backend != "" {
562- if err := validateBackend (backend ); err != nil {
563- return err
564- }
565- }
566-
567- // Validate API key for OpenAI backend
568- apiKey , err := ensureAPIKey (backend )
569- if err != nil {
570- return err
571- }
572-
573559 // Normalize model name to add default org and tag if missing
574560 model := models .NormalizeModelName (args [0 ])
575561 prompt := ""
@@ -608,23 +594,21 @@ func newRunCmd() *cobra.Command {
608594 }
609595
610596 // Do not validate the model in case of using OpenAI's backend, let OpenAI handle it
611- if backend != "openai" {
612- _ , err := desktopClient .Inspect (model , false )
613- if err != nil {
614- if ! errors .Is (err , desktop .ErrNotFound ) {
615- return handleNotRunningError (handleClientError (err , "Failed to inspect model" ))
616- }
617- cmd .Println ("Unable to find model '" + model + "' locally. Pulling from the server." )
618- if err := pullModel (cmd , desktopClient , model , ignoreRuntimeMemoryCheck ); err != nil {
619- return err
620- }
597+ _ , err := desktopClient .Inspect (model , false )
598+ if err != nil {
599+ if ! errors .Is (err , desktop .ErrNotFound ) {
600+ return handleNotRunningError (handleClientError (err , "Failed to inspect model" ))
601+ }
602+ cmd .Println ("Unable to find model '" + model + "' locally. Pulling from the server." )
603+ if err := pullModel (cmd , desktopClient , model , ignoreRuntimeMemoryCheck ); err != nil {
604+ return err
621605 }
622606 }
623607
624608 // Handle --detach flag: just load the model without interaction
625609 if detach {
626610 // Make a minimal request to load the model into memory
627- err := desktopClient .Chat (backend , model , "" , apiKey , nil , func (content string ) {
611+ err := desktopClient .Chat (model , "" , nil , func (content string ) {
628612 // Silently discard output in detach mode
629613 }, false )
630614 if err != nil {
@@ -637,7 +621,7 @@ func newRunCmd() *cobra.Command {
637621 }
638622
639623 if prompt != "" {
640- if err := chatWithMarkdown (cmd , desktopClient , backend , model , prompt , apiKey ); err != nil {
624+ if err := chatWithMarkdown (cmd , desktopClient , model , prompt ); err != nil {
641625 return handleClientError (err , "Failed to generate a response" )
642626 }
643627 cmd .Println ()
@@ -646,11 +630,11 @@ func newRunCmd() *cobra.Command {
646630
647631 // Use enhanced readline-based interactive mode when terminal is available
648632 if term .IsTerminal (int (os .Stdin .Fd ())) {
649- return generateInteractiveWithReadline (cmd , desktopClient , backend , model , apiKey )
633+ return generateInteractiveWithReadline (cmd , desktopClient , model )
650634 }
651635
652636 // Fall back to basic mode if not a terminal
653- return generateInteractiveBasic (cmd , desktopClient , backend , model , apiKey )
637+ return generateInteractiveBasic (cmd , desktopClient , model )
654638 },
655639 ValidArgsFunction : completion .ModelNames (getDesktopClient , 1 ),
656640 }
@@ -667,8 +651,6 @@ func newRunCmd() *cobra.Command {
667651 }
668652
669653 c .Flags ().BoolVar (& debug , "debug" , false , "Enable debug logging" )
670- c .Flags ().StringVar (& backend , "backend" , "" , fmt .Sprintf ("Specify the backend to use (%s)" , ValidBackendsKeys ()))
671- c .Flags ().MarkHidden ("backend" )
672654 c .Flags ().BoolVar (& ignoreRuntimeMemoryCheck , "ignore-runtime-memory-check" , false , "Do not block pull if estimated runtime memory for model exceeds system resources." )
673655 c .Flags ().StringVar (& colorMode , "color" , "auto" , "Use colored output (auto|yes|no)" )
674656 c .Flags ().BoolVarP (& detach , "detach" , "d" , false , "Load the model in the background without interaction" )
0 commit comments