Go: implement provider: Nvidia (#14623)

### What problem does this PR solve?

1. **Implement `Nvidia` Provider:** Fully support NVIDIA NIM APIs with
robust parameter handling (including the `thinking` parameter) and safe
URL merging in `NewInstance`.
2. **Fix Misleading CLI Errors:** Corrected a bug in `common_command.go`
where failed chat requests inaccurately reported `failed to list
instance models`.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
Haruko386
2026-05-07 14:17:57 +08:00
committed by GitHub
parent 911671cef0
commit 078ea3bf4a
4 changed files with 821 additions and 3 deletions

View File

@@ -21,7 +21,10 @@ import (
"context"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"io"
"net"
netUrl "net/url"
"os"
ce "ragflow/internal/cli/filesystem"
@@ -1755,7 +1758,16 @@ func (c *RAGFlowClient) ChatToModel(cmd *Command) (ResponseIf, error) {
resp, err := c.HTTPClient.Request("POST", url, true, "web", nil, payload)
if err != nil {
return nil, fmt.Errorf("failed to list instance models: %w", err)
if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) {
return nil, fmt.Errorf("connection closed (EOF): upstream overloaded or proxy timeout: %w", err)
}
var netErr net.Error
if errors.As(err, &netErr) && netErr.Timeout() {
return nil, fmt.Errorf("request timeout: model took too long to respond: %w", err)
}
return nil, fmt.Errorf("request failed: %w", err)
}
if resp.StatusCode != 200 {