mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-27 02:42:00 +08:00
Go: refactor provider code (#15564)
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
@@ -52,15 +52,15 @@ func NewAliyunModel(baseURL map[string]string, urlSuffix URLSuffix) *AliyunModel
|
||||
}
|
||||
}
|
||||
|
||||
func (z *AliyunModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
func (a *AliyunModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (z *AliyunModel) Name() string {
|
||||
func (a *AliyunModel) Name() string {
|
||||
return "aliyun"
|
||||
}
|
||||
|
||||
func (z *AliyunModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
func (a *AliyunModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
if len(messages) == 0 {
|
||||
return nil, fmt.Errorf("messages is empty")
|
||||
}
|
||||
@@ -70,12 +70,12 @@ func (z *AliyunModel) ChatWithMessages(modelName string, messages []Message, api
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL, ok := z.BaseURL[region]
|
||||
baseURL, ok := a.BaseURL[region]
|
||||
if !ok || baseURL == "" {
|
||||
return nil, fmt.Errorf("aliyun: no base URL configured for region %q", region)
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", strings.TrimSuffix(baseURL, "/"), z.URLSuffix.Chat)
|
||||
url := fmt.Sprintf("%s/%s", strings.TrimSuffix(baseURL, "/"), a.URLSuffix.Chat)
|
||||
|
||||
// Convert messages to the format expected by API
|
||||
apiMessages := make([]map[string]interface{}, len(messages))
|
||||
@@ -142,7 +142,7 @@ func (z *AliyunModel) ChatWithMessages(modelName string, messages []Message, api
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
}
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := a.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -204,7 +204,7 @@ func (z *AliyunModel) ChatWithMessages(modelName string, messages []Message, api
|
||||
}
|
||||
|
||||
// ChatStreamlyWithSender sends messages and streams response via sender function (best performance, no channel)
|
||||
func (z *AliyunModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
func (a *AliyunModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
if len(messages) == 0 {
|
||||
return fmt.Errorf("messages is empty")
|
||||
}
|
||||
@@ -214,12 +214,12 @@ func (z *AliyunModel) ChatStreamlyWithSender(modelName string, messages []Messag
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL, ok := z.BaseURL[region]
|
||||
baseURL, ok := a.BaseURL[region]
|
||||
if !ok || baseURL == "" {
|
||||
return fmt.Errorf("aliyun: no base URL configured for region %q", region)
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", strings.TrimSuffix(baseURL, "/"), z.URLSuffix.Chat)
|
||||
url := fmt.Sprintf("%s/%s", strings.TrimSuffix(baseURL, "/"), a.URLSuffix.Chat)
|
||||
|
||||
// Convert messages to API format
|
||||
apiMessages := make([]map[string]interface{}, len(messages))
|
||||
@@ -286,7 +286,7 @@ func (z *AliyunModel) ChatStreamlyWithSender(modelName string, messages []Messag
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := a.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -387,7 +387,7 @@ type aliyunUsage struct {
|
||||
}
|
||||
|
||||
// Embed embeds a list of texts into embeddings
|
||||
func (z *AliyunModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
func (a *AliyunModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
if len(texts) == 0 {
|
||||
return []EmbeddingData{}, nil
|
||||
}
|
||||
@@ -405,9 +405,9 @@ func (z *AliyunModel) Embed(modelName *string, texts []string, apiConfig *APICon
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL := z.BaseURL["default"]
|
||||
baseURL := a.BaseURL["default"]
|
||||
if region != "default" {
|
||||
if regional, ok := z.BaseURL[region]; ok && regional != "" {
|
||||
if regional, ok := a.BaseURL[region]; ok && regional != "" {
|
||||
baseURL = regional
|
||||
}
|
||||
}
|
||||
@@ -415,7 +415,7 @@ func (z *AliyunModel) Embed(modelName *string, texts []string, apiConfig *APICon
|
||||
return nil, fmt.Errorf("aliyun: no base URL configured for default region")
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", strings.TrimSuffix(baseURL, "/"), z.URLSuffix.Embedding)
|
||||
url := fmt.Sprintf("%s/%s", strings.TrimSuffix(baseURL, "/"), a.URLSuffix.Embedding)
|
||||
|
||||
reqBody := map[string]interface{}{
|
||||
"model": *modelName,
|
||||
@@ -438,7 +438,7 @@ func (z *AliyunModel) Embed(modelName *string, texts []string, apiConfig *APICon
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := a.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -484,7 +484,7 @@ type aliyunRerankResponse struct {
|
||||
} `json:"results"`
|
||||
}
|
||||
|
||||
func (z *AliyunModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
func (a *AliyunModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
if len(documents) == 0 {
|
||||
return &RerankResponse{}, nil
|
||||
}
|
||||
@@ -500,9 +500,9 @@ func (z *AliyunModel) Rerank(modelName *string, query string, documents []string
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL := z.BaseURL["default"]
|
||||
baseURL := a.BaseURL["default"]
|
||||
if region != "default" {
|
||||
if regional, ok := z.BaseURL[region]; ok && regional != "" {
|
||||
if regional, ok := a.BaseURL[region]; ok && regional != "" {
|
||||
baseURL = regional
|
||||
}
|
||||
}
|
||||
@@ -510,7 +510,7 @@ func (z *AliyunModel) Rerank(modelName *string, query string, documents []string
|
||||
return nil, fmt.Errorf("aliyun: no base URL configured for default region")
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", strings.TrimSuffix(baseURL, "/"), z.URLSuffix.Rerank)
|
||||
url := fmt.Sprintf("%s/%s", strings.TrimSuffix(baseURL, "/"), a.URLSuffix.Rerank)
|
||||
|
||||
var topN = rerankConfig.TopN
|
||||
if rerankConfig.TopN == 0 {
|
||||
@@ -541,7 +541,7 @@ func (z *AliyunModel) Rerank(modelName *string, query string, documents []string
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := a.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -565,31 +565,31 @@ func (z *AliyunModel) Rerank(modelName *string, query string, documents []string
|
||||
}
|
||||
|
||||
// TranscribeAudio transcribe audio
|
||||
func (z *AliyunModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (a *AliyunModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
}
|
||||
|
||||
func (z *AliyunModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (a *AliyunModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", a.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech convert text to audio
|
||||
func (z *AliyunModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (a *AliyunModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
}
|
||||
|
||||
func (z *AliyunModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (a *AliyunModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", a.Name())
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
func (z *AliyunModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (a *AliyunModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *AliyunModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (a *AliyunModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
}
|
||||
|
||||
type AliyunModelItem struct {
|
||||
@@ -609,18 +609,18 @@ type AliyunModelList struct {
|
||||
Output AliyunModelOutput `json:"output"`
|
||||
}
|
||||
|
||||
func (z *AliyunModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
func (a *AliyunModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
var region = "default"
|
||||
if apiConfig.Region != nil {
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL, ok := z.BaseURL[region]
|
||||
baseURL, ok := a.BaseURL[region]
|
||||
if !ok || baseURL == "" {
|
||||
return nil, fmt.Errorf("aliyun: no base URL configured for region %q", region)
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", strings.TrimSuffix(baseURL, "/"), z.URLSuffix.Models)
|
||||
url := fmt.Sprintf("%s/%s", strings.TrimSuffix(baseURL, "/"), a.URLSuffix.Models)
|
||||
|
||||
// Build request body
|
||||
reqBody := map[string]interface{}{}
|
||||
@@ -641,7 +641,7 @@ func (z *AliyunModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := a.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -671,22 +671,22 @@ func (z *AliyunModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
return models, nil
|
||||
}
|
||||
|
||||
func (z *AliyunModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (a *AliyunModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
}
|
||||
|
||||
func (z *AliyunModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := z.ListModels(apiConfig)
|
||||
func (a *AliyunModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := a.ListModels(apiConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (z *AliyunModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (a *AliyunModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
}
|
||||
|
||||
func (z *AliyunModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (a *AliyunModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
}
|
||||
|
||||
@@ -77,19 +77,19 @@ func NewAzureOpenAIModel(baseURL map[string]string, urlSuffix URLSuffix) *AzureO
|
||||
}
|
||||
}
|
||||
|
||||
func (z *AzureOpenAIModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return NewAzureOpenAIModel(baseURL, z.URLSuffix)
|
||||
func (a *AzureOpenAIModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return NewAzureOpenAIModel(baseURL, a.URLSuffix)
|
||||
}
|
||||
|
||||
func (z *AzureOpenAIModel) Name() string {
|
||||
func (a *AzureOpenAIModel) Name() string {
|
||||
return "azure-openai"
|
||||
}
|
||||
|
||||
// baseURLForRegion returns the base URL for the given region, or an error if
|
||||
// no entry exists. A misconfigured region fails fast with a clear message
|
||||
// instead of silently producing a relative URL the transport then rejects.
|
||||
func (z *AzureOpenAIModel) baseURLForRegion(region string) (string, error) {
|
||||
base, ok := z.BaseURL[region]
|
||||
func (a *AzureOpenAIModel) baseURLForRegion(region string) (string, error) {
|
||||
base, ok := a.BaseURL[region]
|
||||
if !ok || base == "" {
|
||||
return "", fmt.Errorf("azure-openai: no base URL configured for region %q", region)
|
||||
}
|
||||
@@ -98,13 +98,13 @@ func (z *AzureOpenAIModel) baseURLForRegion(region string) (string, error) {
|
||||
|
||||
// deploymentURL builds a deployment-scoped data-plane URL of the form
|
||||
// {baseURL}/deployments/{deployment}/{op}?api-version={azureAPIVersion}.
|
||||
func (z *AzureOpenAIModel) deploymentURL(baseURL, deployment, op string) string {
|
||||
func (a *AzureOpenAIModel) deploymentURL(baseURL, deployment, op string) string {
|
||||
return fmt.Sprintf("%s/deployments/%s/%s?api-version=%s",
|
||||
strings.TrimRight(baseURL, "/"), deployment, op, azureAPIVersion)
|
||||
}
|
||||
|
||||
// ChatWithMessages sends multiple messages with roles and returns the response.
|
||||
func (z *AzureOpenAIModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
func (a *AzureOpenAIModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
if apiConfig == nil || apiConfig.ApiKey == nil || *apiConfig.ApiKey == "" {
|
||||
return nil, fmt.Errorf("api key is required")
|
||||
}
|
||||
@@ -122,11 +122,11 @@ func (z *AzureOpenAIModel) ChatWithMessages(modelName string, messages []Message
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL, err := z.baseURLForRegion(region)
|
||||
baseURL, err := a.baseURLForRegion(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
url := z.deploymentURL(baseURL, modelName, z.URLSuffix.Chat)
|
||||
url := a.deploymentURL(baseURL, modelName, a.URLSuffix.Chat)
|
||||
|
||||
apiMessages := make([]map[string]interface{}, len(messages))
|
||||
for i, msg := range messages {
|
||||
@@ -175,7 +175,7 @@ func (z *AzureOpenAIModel) ChatWithMessages(modelName string, messages []Message
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("api-key", *apiConfig.ApiKey)
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := a.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -231,7 +231,7 @@ func (z *AzureOpenAIModel) ChatWithMessages(modelName string, messages []Message
|
||||
|
||||
// ChatStreamlyWithSender sends messages and streams the response via the
|
||||
// sender function. Used for streaming chat responses with no extra channel.
|
||||
func (z *AzureOpenAIModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
func (a *AzureOpenAIModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
if len(messages) == 0 {
|
||||
return fmt.Errorf("messages is empty")
|
||||
}
|
||||
@@ -253,11 +253,11 @@ func (z *AzureOpenAIModel) ChatStreamlyWithSender(modelName string, messages []M
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL, err := z.baseURLForRegion(region)
|
||||
baseURL, err := a.baseURLForRegion(region)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
url := z.deploymentURL(baseURL, modelName, z.URLSuffix.Chat)
|
||||
url := a.deploymentURL(baseURL, modelName, a.URLSuffix.Chat)
|
||||
|
||||
apiMessages := make([]map[string]interface{}, len(messages))
|
||||
for i, msg := range messages {
|
||||
@@ -308,7 +308,7 @@ func (z *AzureOpenAIModel) ChatStreamlyWithSender(modelName string, messages []M
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("api-key", *apiConfig.ApiKey)
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := a.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -401,7 +401,7 @@ type azureEmbeddingResponse struct {
|
||||
// Embed turns a list of texts into embedding vectors using the Azure OpenAI
|
||||
// embeddings deployment. The output has one vector per input, in the same
|
||||
// order the inputs were given.
|
||||
func (z *AzureOpenAIModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
func (a *AzureOpenAIModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
if len(texts) == 0 {
|
||||
return []EmbeddingData{}, nil
|
||||
}
|
||||
@@ -419,11 +419,11 @@ func (z *AzureOpenAIModel) Embed(modelName *string, texts []string, apiConfig *A
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL, err := z.baseURLForRegion(region)
|
||||
baseURL, err := a.baseURLForRegion(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
url := z.deploymentURL(baseURL, *modelName, z.URLSuffix.Embedding)
|
||||
url := a.deploymentURL(baseURL, *modelName, a.URLSuffix.Embedding)
|
||||
|
||||
// As with chat, the deployment is in the URL path, so no "model" field.
|
||||
reqBody := map[string]interface{}{
|
||||
@@ -449,7 +449,7 @@ func (z *AzureOpenAIModel) Embed(modelName *string, texts []string, apiConfig *A
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("api-key", *apiConfig.ApiKey)
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := a.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -490,7 +490,7 @@ func (z *AzureOpenAIModel) Embed(modelName *string, texts []string, apiConfig *A
|
||||
// ListModels returns the deployment names visible to the configured API key.
|
||||
// Azure exposes deployments (not a shared model catalog) at
|
||||
// {baseURL}/deployments?api-version={azureAPIVersion}.
|
||||
func (z *AzureOpenAIModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
func (a *AzureOpenAIModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
if apiConfig == nil || apiConfig.ApiKey == nil || *apiConfig.ApiKey == "" {
|
||||
return nil, fmt.Errorf("api key is required")
|
||||
}
|
||||
@@ -500,12 +500,12 @@ func (z *AzureOpenAIModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL, err := z.baseURLForRegion(region)
|
||||
baseURL, err := a.baseURLForRegion(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
url := fmt.Sprintf("%s/%s?api-version=%s",
|
||||
strings.TrimRight(baseURL, "/"), z.URLSuffix.Models, azureAPIVersion)
|
||||
strings.TrimRight(baseURL, "/"), a.URLSuffix.Models, azureAPIVersion)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), nonStreamCallTimeout)
|
||||
defer cancel()
|
||||
@@ -517,7 +517,7 @@ func (z *AzureOpenAIModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
|
||||
req.Header.Set("api-key", *apiConfig.ApiKey)
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := a.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -561,49 +561,49 @@ func (z *AzureOpenAIModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
|
||||
// CheckConnection runs a lightweight ListModels call to verify the endpoint
|
||||
// and API key.
|
||||
func (z *AzureOpenAIModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := z.ListModels(apiConfig)
|
||||
func (a *AzureOpenAIModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := a.ListModels(apiConfig)
|
||||
return err
|
||||
}
|
||||
|
||||
// Balance is not exposed by the Azure OpenAI API.
|
||||
func (z *AzureOpenAIModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
func (a *AzureOpenAIModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
return nil, fmt.Errorf("no such method")
|
||||
}
|
||||
|
||||
// Rerank is not exposed by the Azure OpenAI API.
|
||||
func (z *AzureOpenAIModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (a *AzureOpenAIModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
}
|
||||
|
||||
func (z *AzureOpenAIModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (a *AzureOpenAIModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
}
|
||||
|
||||
func (z *AzureOpenAIModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (a *AzureOpenAIModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", a.Name())
|
||||
}
|
||||
|
||||
func (z *AzureOpenAIModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (a *AzureOpenAIModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
}
|
||||
|
||||
func (z *AzureOpenAIModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (a *AzureOpenAIModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", a.Name())
|
||||
}
|
||||
|
||||
func (z *AzureOpenAIModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (a *AzureOpenAIModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
}
|
||||
|
||||
func (z *AzureOpenAIModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (a *AzureOpenAIModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
}
|
||||
|
||||
func (z *AzureOpenAIModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (a *AzureOpenAIModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
}
|
||||
|
||||
func (z *AzureOpenAIModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (a *AzureOpenAIModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
}
|
||||
|
||||
@@ -390,31 +390,31 @@ func (b *BaichuanModel) Rerank(modelName *string, query string, documents []stri
|
||||
}
|
||||
|
||||
// TranscribeAudio transcribe audio
|
||||
func (z *BaichuanModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (b *BaichuanModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", b.Name())
|
||||
}
|
||||
|
||||
func (z *BaichuanModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (b *BaichuanModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", b.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech convert text to audio
|
||||
func (z *BaichuanModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (b *BaichuanModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", b.Name())
|
||||
}
|
||||
|
||||
func (z *BaichuanModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (b *BaichuanModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", b.Name())
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
func (z *BaichuanModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (b *BaichuanModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", b.Name())
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *BaichuanModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (b *BaichuanModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", b.Name())
|
||||
}
|
||||
|
||||
func (b *BaichuanModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
@@ -429,10 +429,10 @@ func (b *BaichuanModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
return fmt.Errorf("no such method")
|
||||
}
|
||||
|
||||
func (z *BaichuanModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (b *BaichuanModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", b.Name())
|
||||
}
|
||||
|
||||
func (z *BaichuanModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (b *BaichuanModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", b.Name())
|
||||
}
|
||||
|
||||
@@ -620,8 +620,8 @@ func (b *BaiduModel) TranscribeAudio(modelName *string, file *string, apiConfig
|
||||
return nil, fmt.Errorf("%s, no such method", b.Name())
|
||||
}
|
||||
|
||||
func (z *BaiduModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (b *BaiduModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", b.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech convert text to audio
|
||||
@@ -629,8 +629,8 @@ func (b *BaiduModel) AudioSpeech(modelName *string, audioContent *string, apiCon
|
||||
return nil, fmt.Errorf("%s, no such method", b.Name())
|
||||
}
|
||||
|
||||
func (z *BaiduModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (b *BaiduModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", b.Name())
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
@@ -802,14 +802,14 @@ func (b *BaiduModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (z *BaiduModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (b *BaiduModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", b.Name())
|
||||
}
|
||||
|
||||
func (z *BaiduModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (b *BaiduModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", b.Name())
|
||||
}
|
||||
|
||||
func (z *BaiduModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (b *BaiduModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", b.Name())
|
||||
}
|
||||
|
||||
@@ -604,8 +604,8 @@ func (c *CoHereModel) TranscribeAudio(modelName *string, file *string, apiConfig
|
||||
return &ASRResponse{Text: result.Text}, nil
|
||||
}
|
||||
|
||||
func (z *CoHereModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (c *CoHereModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", c.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech convert text to audio
|
||||
@@ -613,8 +613,8 @@ func (c *CoHereModel) AudioSpeech(modelName *string, audioContent *string, apiCo
|
||||
return nil, fmt.Errorf("%s, no such method", c.Name())
|
||||
}
|
||||
|
||||
func (z *CoHereModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (c *CoHereModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", c.Name())
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
@@ -623,8 +623,8 @@ func (c *CoHereModel) OCRFile(modelName *string, content []byte, url *string, ap
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *CoHereModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (c *CoHereModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", c.Name())
|
||||
}
|
||||
|
||||
func (c *CoHereModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
@@ -693,10 +693,10 @@ func (c *CoHereModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (z *CoHereModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (c *CoHereModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", c.Name())
|
||||
}
|
||||
|
||||
func (z *CoHereModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (c *CoHereModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", c.Name())
|
||||
}
|
||||
|
||||
@@ -73,11 +73,11 @@ func NewCometAPIModel(baseURL map[string]string, urlSuffix URLSuffix) *CometAPIM
|
||||
}
|
||||
}
|
||||
|
||||
func (m *CometAPIModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return NewCometAPIModel(baseURL, m.URLSuffix)
|
||||
func (c *CometAPIModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return NewCometAPIModel(baseURL, c.URLSuffix)
|
||||
}
|
||||
|
||||
func (m *CometAPIModel) Name() string {
|
||||
func (c *CometAPIModel) Name() string {
|
||||
return "cometapi"
|
||||
}
|
||||
|
||||
@@ -106,24 +106,24 @@ func cometapiRegion(apiConfig *APIConfig) string {
|
||||
// error if no entry exists. This makes a misconfigured region fail
|
||||
// fast with a clear message, instead of silently producing a relative
|
||||
// URL that the HTTP transport then rejects.
|
||||
func (m *CometAPIModel) baseURLForRegion(region string) (string, error) {
|
||||
base, ok := m.BaseURL[region]
|
||||
func (c *CometAPIModel) baseURLForRegion(region string) (string, error) {
|
||||
base, ok := c.BaseURL[region]
|
||||
if !ok || base == "" {
|
||||
return "", fmt.Errorf("cometapi: no base URL configured for region %q", region)
|
||||
}
|
||||
return strings.TrimRight(base, "/"), nil
|
||||
}
|
||||
|
||||
func (m *CometAPIModel) endpointURL(region, suffix string) (string, error) {
|
||||
baseURL, err := m.baseURLForRegion(region)
|
||||
func (c *CometAPIModel) endpointURL(region, suffix string) (string, error) {
|
||||
baseURL, err := c.baseURLForRegion(region)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return fmt.Sprintf("%s/%s", baseURL, strings.TrimLeft(suffix, "/")), nil
|
||||
}
|
||||
|
||||
func (m *CometAPIModel) balanceURL(apiKey string) string {
|
||||
rawURL := strings.TrimSpace(m.URLSuffix.Balance)
|
||||
func (c *CometAPIModel) balanceURL(apiKey string) string {
|
||||
rawURL := strings.TrimSpace(c.URLSuffix.Balance)
|
||||
if !strings.HasPrefix(rawURL, "http://") && !strings.HasPrefix(rawURL, "https://") {
|
||||
rawURL = fmt.Sprintf("https://query.cometapi.com/%s", strings.TrimLeft(rawURL, "/"))
|
||||
}
|
||||
@@ -198,8 +198,8 @@ type cometapiHTTPResponse struct {
|
||||
Body []byte
|
||||
}
|
||||
|
||||
func (m *CometAPIModel) doCometAPIRequest(req *http.Request) (*cometapiHTTPResponse, error) {
|
||||
resp, err := m.httpClient.Do(req)
|
||||
func (c *CometAPIModel) doCometAPIRequest(req *http.Request) (*cometapiHTTPResponse, error) {
|
||||
resp, err := c.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -293,7 +293,7 @@ func parseCometAPIModelCatalog(body []byte) ([]string, error) {
|
||||
}
|
||||
|
||||
// ChatWithMessages sends multiple messages with roles and returns the response.
|
||||
func (m *CometAPIModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
func (c *CometAPIModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
apiKey, err := validateCometAPIAPIKey(apiConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -306,7 +306,7 @@ func (m *CometAPIModel) ChatWithMessages(modelName string, messages []Message, a
|
||||
return nil, fmt.Errorf("messages is empty")
|
||||
}
|
||||
|
||||
url, err := m.endpointURL(cometapiRegion(apiConfig), m.URLSuffix.Chat)
|
||||
url, err := c.endpointURL(cometapiRegion(apiConfig), c.URLSuffix.Chat)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -323,7 +323,7 @@ func (m *CometAPIModel) ChatWithMessages(modelName string, messages []Message, a
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := m.doCometAPIRequest(req)
|
||||
resp, err := c.doCometAPIRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -337,7 +337,7 @@ func (m *CometAPIModel) ChatWithMessages(modelName string, messages []Message, a
|
||||
// ChatStreamlyWithSender sends messages and streams the response via the
|
||||
// sender function. The CometAPI SSE stream uses the same shape as OpenAI:
|
||||
// "data:" lines carrying JSON events, with a final "[DONE]" line.
|
||||
func (m *CometAPIModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
func (c *CometAPIModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
if sender == nil {
|
||||
return fmt.Errorf("sender is required")
|
||||
}
|
||||
@@ -355,7 +355,7 @@ func (m *CometAPIModel) ChatStreamlyWithSender(modelName string, messages []Mess
|
||||
return err
|
||||
}
|
||||
|
||||
url, err := m.endpointURL(cometapiRegion(apiConfig), m.URLSuffix.Chat)
|
||||
url, err := c.endpointURL(cometapiRegion(apiConfig), c.URLSuffix.Chat)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -378,7 +378,7 @@ func (m *CometAPIModel) ChatStreamlyWithSender(modelName string, messages []Mess
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resp, err := m.httpClient.Do(req)
|
||||
resp, err := c.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -467,7 +467,7 @@ type cometapiEmbeddingRequest struct {
|
||||
// Embed turns a list of texts into embedding vectors using the
|
||||
// CometAPI /v1/embeddings endpoint. The output has one vector per input,
|
||||
// in the same order the inputs were given.
|
||||
func (m *CometAPIModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
func (c *CometAPIModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
if len(texts) == 0 {
|
||||
return []EmbeddingData{}, nil
|
||||
}
|
||||
@@ -481,7 +481,7 @@ func (m *CometAPIModel) Embed(modelName *string, texts []string, apiConfig *APIC
|
||||
return nil, fmt.Errorf("model name is required")
|
||||
}
|
||||
|
||||
url, err := m.endpointURL(cometapiRegion(apiConfig), m.URLSuffix.Embedding)
|
||||
url, err := c.endpointURL(cometapiRegion(apiConfig), c.URLSuffix.Embedding)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -502,7 +502,7 @@ func (m *CometAPIModel) Embed(modelName *string, texts []string, apiConfig *APIC
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := m.doCometAPIRequest(req)
|
||||
resp, err := c.doCometAPIRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -548,8 +548,8 @@ func (m *CometAPIModel) Embed(modelName *string, texts []string, apiConfig *APIC
|
||||
}
|
||||
|
||||
// ListModels returns the public CometAPI model catalog.
|
||||
func (m *CometAPIModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
url, err := m.endpointURL(cometapiRegion(apiConfig), m.URLSuffix.Models)
|
||||
func (c *CometAPIModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
url, err := c.endpointURL(cometapiRegion(apiConfig), c.URLSuffix.Models)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -562,7 +562,7 @@ func (m *CometAPIModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
return nil, fmt.Errorf("failed to create request: %w", err)
|
||||
}
|
||||
|
||||
resp, err := m.doCometAPIRequest(req)
|
||||
resp, err := c.doCometAPIRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -574,24 +574,24 @@ func (m *CometAPIModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
}
|
||||
|
||||
// Balance queries CometAPI's quota service. Unlike model requests, this
|
||||
// endpoint authenticates with the key query parameter on query.cometapi.com.
|
||||
func (m *CometAPIModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
// endpoint authenticates with the key query parameter on query.cometapi.coc.
|
||||
func (c *CometAPIModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
if apiConfig == nil || apiConfig.ApiKey == nil || *apiConfig.ApiKey == "" {
|
||||
return nil, fmt.Errorf("api key is required")
|
||||
}
|
||||
if strings.TrimSpace(m.URLSuffix.Balance) == "" {
|
||||
if strings.TrimSpace(c.URLSuffix.Balance) == "" {
|
||||
return nil, fmt.Errorf("balance URL is required")
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), nonStreamCallTimeout)
|
||||
defer cancel()
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", m.balanceURL(*apiConfig.ApiKey), nil)
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", c.balanceURL(*apiConfig.ApiKey), nil)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create request: %w", err)
|
||||
}
|
||||
|
||||
resp, err := m.doCometAPIRequest(req)
|
||||
resp, err := c.doCometAPIRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -609,8 +609,8 @@ func (m *CometAPIModel) Balance(apiConfig *APIConfig) (map[string]interface{}, e
|
||||
}
|
||||
|
||||
// CheckConnection runs a quota query to verify the API key.
|
||||
func (m *CometAPIModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := m.Balance(apiConfig)
|
||||
func (c *CometAPIModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := c.Balance(apiConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -619,12 +619,12 @@ func (m *CometAPIModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
|
||||
// Rerank calculates similarity scores between query and documents. CometAPI
|
||||
// does not expose a public rerank API, so this returns "no such method".
|
||||
func (m *CometAPIModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
func (c *CometAPIModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
return nil, fmt.Errorf("no such method")
|
||||
}
|
||||
|
||||
// TranscribeAudio transcribe audio
|
||||
func (m *CometAPIModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
func (c *CometAPIModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
if file == nil || *file == "" {
|
||||
return nil, fmt.Errorf("file is missing")
|
||||
}
|
||||
@@ -634,7 +634,7 @@ func (m *CometAPIModel) TranscribeAudio(modelName *string, file *string, apiConf
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", m.BaseURL[region], m.URLSuffix.ASR)
|
||||
url := fmt.Sprintf("%s/%s", c.BaseURL[region], c.URLSuffix.ASR)
|
||||
|
||||
// multipart body
|
||||
var body bytes.Buffer
|
||||
@@ -707,7 +707,7 @@ func (m *CometAPIModel) TranscribeAudio(modelName *string, file *string, apiConf
|
||||
req.Header.Set("Accept", "application/json")
|
||||
|
||||
// send request
|
||||
resp, err := m.httpClient.Do(req)
|
||||
resp, err := c.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -734,12 +734,12 @@ func (m *CometAPIModel) TranscribeAudio(modelName *string, file *string, apiConf
|
||||
return &ASRResponse{Text: result.Text}, nil
|
||||
}
|
||||
|
||||
func (m *CometAPIModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", m.Name())
|
||||
func (c *CometAPIModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", c.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech synthesizes speech audio from text.
|
||||
func (m *CometAPIModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
func (c *CometAPIModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
if audioContent == nil || *audioContent == "" {
|
||||
return nil, fmt.Errorf("audio content is empty")
|
||||
}
|
||||
@@ -749,7 +749,7 @@ func (m *CometAPIModel) AudioSpeech(modelName *string, audioContent *string, api
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", m.BaseURL[region], m.URLSuffix.TTS)
|
||||
url := fmt.Sprintf("%s/%s", c.BaseURL[region], c.URLSuffix.TTS)
|
||||
|
||||
reqBody := map[string]interface{}{
|
||||
"model": *modelName,
|
||||
@@ -778,7 +778,7 @@ func (m *CometAPIModel) AudioSpeech(modelName *string, audioContent *string, api
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := m.httpClient.Do(req)
|
||||
resp, err := c.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -796,23 +796,23 @@ func (m *CometAPIModel) AudioSpeech(modelName *string, audioContent *string, api
|
||||
return &TTSResponse{Audio: body}, nil
|
||||
}
|
||||
|
||||
func (m *CometAPIModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", m.Name())
|
||||
func (c *CometAPIModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", c.Name())
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
func (m *CometAPIModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (c *CometAPIModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", c.Name())
|
||||
}
|
||||
|
||||
func (m *CometAPIModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (c *CometAPIModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", c.Name())
|
||||
}
|
||||
|
||||
func (m *CometAPIModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (c *CometAPIModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", c.Name())
|
||||
}
|
||||
|
||||
func (m *CometAPIModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (c *CometAPIModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", c.Name())
|
||||
}
|
||||
|
||||
@@ -53,15 +53,15 @@ func NewDeepSeekModel(baseURL map[string]string, urlSuffix URLSuffix) *DeepSeekM
|
||||
}
|
||||
}
|
||||
|
||||
func (z *DeepSeekModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
func (d *DeepSeekModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (z *DeepSeekModel) Name() string {
|
||||
func (d *DeepSeekModel) Name() string {
|
||||
return "deepseek"
|
||||
}
|
||||
|
||||
func (z *DeepSeekModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
func (d *DeepSeekModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
if len(messages) == 0 {
|
||||
return nil, fmt.Errorf("messages is empty")
|
||||
}
|
||||
@@ -71,7 +71,7 @@ func (z *DeepSeekModel) ChatWithMessages(modelName string, messages []Message, a
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", z.BaseURL[region], z.URLSuffix.Chat)
|
||||
url := fmt.Sprintf("%s/%s", d.BaseURL[region], d.URLSuffix.Chat)
|
||||
|
||||
// Convert messages to the format expected by API
|
||||
apiMessages := make([]map[string]interface{}, len(messages))
|
||||
@@ -170,7 +170,7 @@ func (z *DeepSeekModel) ChatWithMessages(modelName string, messages []Message, a
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
}
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := d.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -232,7 +232,7 @@ func (z *DeepSeekModel) ChatWithMessages(modelName string, messages []Message, a
|
||||
}
|
||||
|
||||
// ChatStreamlyWithSender sends messages and streams response via sender function (best performance, no channel)
|
||||
func (z *DeepSeekModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
func (d *DeepSeekModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
if len(messages) == 0 {
|
||||
return fmt.Errorf("messages is empty")
|
||||
}
|
||||
@@ -242,7 +242,7 @@ func (z *DeepSeekModel) ChatStreamlyWithSender(modelName string, messages []Mess
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/chat/completions", z.BaseURL[region])
|
||||
url := fmt.Sprintf("%s/chat/completions", d.BaseURL[region])
|
||||
|
||||
// Convert messages to API format
|
||||
apiMessages := make([]map[string]interface{}, len(messages))
|
||||
@@ -341,7 +341,7 @@ func (z *DeepSeekModel) ChatStreamlyWithSender(modelName string, messages []Mess
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := d.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -423,8 +423,8 @@ func (z *DeepSeekModel) ChatStreamlyWithSender(modelName string, messages []Mess
|
||||
}
|
||||
|
||||
// Embed embeds a list of texts into embeddings
|
||||
func (z *DeepSeekModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (d *DeepSeekModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", d.Name())
|
||||
}
|
||||
|
||||
type DSModel struct {
|
||||
@@ -438,13 +438,13 @@ type DSModelList struct {
|
||||
Models []DSModel `json:"data"`
|
||||
}
|
||||
|
||||
func (z *DeepSeekModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
func (d *DeepSeekModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
var region = "default"
|
||||
if apiConfig.Region != nil {
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", z.BaseURL[region], z.URLSuffix.Models)
|
||||
url := fmt.Sprintf("%s/%s", d.BaseURL[region], d.URLSuffix.Models)
|
||||
|
||||
// Build request body
|
||||
reqBody := map[string]interface{}{}
|
||||
@@ -465,7 +465,7 @@ func (z *DeepSeekModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := d.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -511,7 +511,7 @@ type deepseekBalanceResponse struct {
|
||||
// calling GET /user/balance with the configured Bearer token.
|
||||
// The result map matches the shape used by the Moonshot driver,
|
||||
// so the UI can render it without provider-specific code.
|
||||
func (z *DeepSeekModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
func (d *DeepSeekModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
if apiConfig == nil || apiConfig.ApiKey == nil || *apiConfig.ApiKey == "" {
|
||||
return nil, fmt.Errorf("api key is required")
|
||||
}
|
||||
@@ -525,9 +525,9 @@ func (z *DeepSeekModel) Balance(apiConfig *APIConfig) (map[string]interface{}, e
|
||||
// supplied but is not configured (or is empty), fall back to the
|
||||
// "default" region instead of erroring out, so a stray region value
|
||||
// does not break an otherwise valid request.
|
||||
baseURL := z.BaseURL["default"]
|
||||
baseURL := d.BaseURL["default"]
|
||||
if region != "default" {
|
||||
if regional, ok := z.BaseURL[region]; ok && regional != "" {
|
||||
if regional, ok := d.BaseURL[region]; ok && regional != "" {
|
||||
baseURL = regional
|
||||
}
|
||||
}
|
||||
@@ -535,7 +535,7 @@ func (z *DeepSeekModel) Balance(apiConfig *APIConfig) (map[string]interface{}, e
|
||||
return nil, fmt.Errorf("deepseek: no base URL configured for default region")
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", strings.TrimSuffix(baseURL, "/"), z.URLSuffix.Balance)
|
||||
url := fmt.Sprintf("%s/%s", strings.TrimSuffix(baseURL, "/"), d.URLSuffix.Balance)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), nonStreamCallTimeout)
|
||||
defer cancel()
|
||||
@@ -547,7 +547,7 @@ func (z *DeepSeekModel) Balance(apiConfig *APIConfig) (map[string]interface{}, e
|
||||
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := d.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -585,8 +585,8 @@ func (z *DeepSeekModel) Balance(apiConfig *APIConfig) (map[string]interface{}, e
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (z *DeepSeekModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := z.ListModels(apiConfig)
|
||||
func (d *DeepSeekModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := d.ListModels(apiConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -594,8 +594,8 @@ func (z *DeepSeekModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
}
|
||||
|
||||
// Rerank calculates similarity scores between query and documents
|
||||
func (z *DeepSeekModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
return nil, fmt.Errorf("%s, Rerank not implemented", z.Name())
|
||||
func (d *DeepSeekModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
return nil, fmt.Errorf("%s, Rerank not implemented", d.Name())
|
||||
}
|
||||
|
||||
// TranscribeAudio transcribe audio
|
||||
@@ -603,8 +603,8 @@ func (d *DeepSeekModel) TranscribeAudio(modelName *string, file *string, apiConf
|
||||
return nil, fmt.Errorf("%s, no such method", d.Name())
|
||||
}
|
||||
|
||||
func (z *DeepSeekModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (d *DeepSeekModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", d.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech convert text to audio
|
||||
@@ -612,8 +612,8 @@ func (d *DeepSeekModel) AudioSpeech(modelName *string, audioContent *string, api
|
||||
return nil, fmt.Errorf("%s, no such method", d.Name())
|
||||
}
|
||||
|
||||
func (z *DeepSeekModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (d *DeepSeekModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", d.Name())
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
@@ -622,14 +622,14 @@ func (d *DeepSeekModel) OCRFile(modelName *string, content []byte, url *string,
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *DeepSeekModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (d *DeepSeekModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", d.Name())
|
||||
}
|
||||
|
||||
func (z *DeepSeekModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (d *DeepSeekModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", d.Name())
|
||||
}
|
||||
|
||||
func (z *DeepSeekModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (d *DeepSeekModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", d.Name())
|
||||
}
|
||||
|
||||
@@ -79,8 +79,8 @@ func (d *DummyModel) TranscribeAudio(modelName *string, file *string, apiConfig
|
||||
return nil, fmt.Errorf("%s, no such method", d.Name())
|
||||
}
|
||||
|
||||
func (z *DummyModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (d *DummyModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", d.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech convert text to audio
|
||||
@@ -88,8 +88,8 @@ func (d *DummyModel) AudioSpeech(modelName *string, audioContent *string, apiCon
|
||||
return nil, fmt.Errorf("%s, no such method", d.Name())
|
||||
}
|
||||
|
||||
func (z *DummyModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (d *DummyModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", d.Name())
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
@@ -98,14 +98,14 @@ func (d *DummyModel) OCRFile(modelName *string, content []byte, url *string, api
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *DummyModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (d *DummyModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", d.Name())
|
||||
}
|
||||
|
||||
func (z *DummyModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (d *DummyModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", d.Name())
|
||||
}
|
||||
|
||||
func (z *DummyModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (d *DummyModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", d.Name())
|
||||
}
|
||||
|
||||
@@ -341,8 +341,8 @@ func (f *FishAudioModel) OCRFile(modelName *string, content []byte, url *string,
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *FishAudioModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (f *FishAudioModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", f.Name())
|
||||
}
|
||||
|
||||
func (f *FishAudioModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
@@ -452,10 +452,10 @@ func (f *FishAudioModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (z *FishAudioModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (f *FishAudioModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", f.Name())
|
||||
}
|
||||
|
||||
func (z *FishAudioModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (f *FishAudioModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", f.Name())
|
||||
}
|
||||
|
||||
@@ -83,27 +83,27 @@ func NewFuturMixModel(baseURL map[string]string, urlSuffix URLSuffix) *FuturMixM
|
||||
}
|
||||
}
|
||||
|
||||
func (m *FuturMixModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return NewFuturMixModel(baseURL, m.URLSuffix)
|
||||
func (f *FuturMixModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return NewFuturMixModel(baseURL, f.URLSuffix)
|
||||
}
|
||||
|
||||
func (m *FuturMixModel) Name() string {
|
||||
func (f *FuturMixModel) Name() string {
|
||||
return "futurmix"
|
||||
}
|
||||
|
||||
// baseURLForRegion returns the base URL for the given region, trimmed
|
||||
// of any trailing slash so callers can append a suffix without
|
||||
// producing "//" in the path.
|
||||
func (m *FuturMixModel) baseURLForRegion(region string) (string, error) {
|
||||
base, ok := m.BaseURL[region]
|
||||
func (f *FuturMixModel) baseURLForRegion(region string) (string, error) {
|
||||
base, ok := f.BaseURL[region]
|
||||
if !ok || base == "" {
|
||||
return "", fmt.Errorf("futurmix: no base URL configured for region %q", region)
|
||||
}
|
||||
return strings.TrimRight(base, "/"), nil
|
||||
}
|
||||
|
||||
func (m *FuturMixModel) endpointURL(region, suffix string) (string, error) {
|
||||
baseURL, err := m.baseURLForRegion(region)
|
||||
func (f *FuturMixModel) endpointURL(region, suffix string) (string, error) {
|
||||
baseURL, err := f.baseURLForRegion(region)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -206,7 +206,7 @@ type futurmixChatResponse struct {
|
||||
// FuturMix's /v1/chat/completions endpoint. Wire shape follows the
|
||||
// OpenAI Chat Completions contract since FuturMix is documented as
|
||||
// "OpenAI-compatible".
|
||||
func (m *FuturMixModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
func (f *FuturMixModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
apiKey, err := futurmixValidateAPIKey(apiConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -218,7 +218,7 @@ func (m *FuturMixModel) ChatWithMessages(modelName string, messages []Message, a
|
||||
return nil, fmt.Errorf("messages is empty")
|
||||
}
|
||||
|
||||
endpoint, err := m.endpointURL(futurmixRegion(apiConfig), m.URLSuffix.Chat)
|
||||
endpoint, err := f.endpointURL(futurmixRegion(apiConfig), f.URLSuffix.Chat)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -236,7 +236,7 @@ func (m *FuturMixModel) ChatWithMessages(modelName string, messages []Message, a
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := m.httpClient.Do(req)
|
||||
resp, err := f.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -280,7 +280,7 @@ func (m *FuturMixModel) ChatWithMessages(modelName string, messages []Message, a
|
||||
// reveals divergence (e.g. routed Claude responses surfacing in
|
||||
// /v1/messages-style chunks) the SSE event parser is where to
|
||||
// intervene.
|
||||
func (m *FuturMixModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
func (f *FuturMixModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
if sender == nil {
|
||||
return fmt.Errorf("sender is required")
|
||||
}
|
||||
@@ -295,7 +295,7 @@ func (m *FuturMixModel) ChatStreamlyWithSender(modelName string, messages []Mess
|
||||
return err
|
||||
}
|
||||
|
||||
endpoint, err := m.endpointURL(futurmixRegion(apiConfig), m.URLSuffix.Chat)
|
||||
endpoint, err := f.endpointURL(futurmixRegion(apiConfig), f.URLSuffix.Chat)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -318,7 +318,7 @@ func (m *FuturMixModel) ChatStreamlyWithSender(modelName string, messages []Mess
|
||||
return err
|
||||
}
|
||||
|
||||
resp, err := m.httpClient.Do(req)
|
||||
resp, err := f.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -436,70 +436,70 @@ func (m *FuturMixModel) ChatStreamlyWithSender(modelName string, messages []Mess
|
||||
}
|
||||
|
||||
// Embed is not exposed by the FuturMix API per the public docs.
|
||||
func (m *FuturMixModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (f *FuturMixModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", f.Name())
|
||||
}
|
||||
|
||||
// Rerank is not exposed by the FuturMix API per the public docs.
|
||||
func (m *FuturMixModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (f *FuturMixModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", f.Name())
|
||||
}
|
||||
|
||||
// ListModels is not documented as a public endpoint by FuturMix.
|
||||
// The shipped catalog in conf/models/futurmix.json is the source of
|
||||
// truth for which models RAGFlow knows about; this method does not
|
||||
// invent a fake live listing.
|
||||
func (m *FuturMixModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (f *FuturMixModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", f.Name())
|
||||
}
|
||||
|
||||
// CheckConnection is not exposed by the FuturMix API. With no
|
||||
// documented /models or /health endpoint, the only way to verify
|
||||
// credentials would be to burn a real chat completion against
|
||||
// tenant quota — return the documented sentinel rather than pretend.
|
||||
func (m *FuturMixModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
return fmt.Errorf("%s, no such method", m.Name())
|
||||
func (f *FuturMixModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
return fmt.Errorf("%s, no such method", f.Name())
|
||||
}
|
||||
|
||||
// Balance is not exposed by the FuturMix public API.
|
||||
func (m *FuturMixModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (f *FuturMixModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", f.Name())
|
||||
}
|
||||
|
||||
// TranscribeAudio is not exposed by the FuturMix API per the docs.
|
||||
func (m *FuturMixModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (f *FuturMixModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", f.Name())
|
||||
}
|
||||
|
||||
func (m *FuturMixModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", m.Name())
|
||||
func (f *FuturMixModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", f.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech is not exposed by the FuturMix API per the docs.
|
||||
func (m *FuturMixModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (f *FuturMixModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", f.Name())
|
||||
}
|
||||
|
||||
func (m *FuturMixModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", m.Name())
|
||||
func (f *FuturMixModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", f.Name())
|
||||
}
|
||||
|
||||
// OCRFile is not exposed by the FuturMix API per the docs.
|
||||
func (m *FuturMixModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (f *FuturMixModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", f.Name())
|
||||
}
|
||||
|
||||
// ParseFile is not exposed by the FuturMix API per the docs.
|
||||
func (m *FuturMixModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (f *FuturMixModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", f.Name())
|
||||
}
|
||||
|
||||
// ListTasks is not exposed by the FuturMix API per the docs.
|
||||
func (m *FuturMixModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (f *FuturMixModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", f.Name())
|
||||
}
|
||||
|
||||
// ShowTask is not exposed by the FuturMix API per the docs.
|
||||
func (m *FuturMixModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (f *FuturMixModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", f.Name())
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ import (
|
||||
type GiteeModel struct {
|
||||
BaseURL map[string]string
|
||||
URLSuffix URLSuffix
|
||||
httpClient *http.Client // Reusable HTTP client with connection pool
|
||||
httpClient *http.Client
|
||||
}
|
||||
|
||||
// NewGiteeModel creates a new Gitee model instance
|
||||
|
||||
@@ -358,8 +358,8 @@ func (g *GoogleModel) TranscribeAudio(modelName *string, file *string, apiConfig
|
||||
return nil, fmt.Errorf("%s, no such method", g.Name())
|
||||
}
|
||||
|
||||
func (z *GoogleModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (g *GoogleModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", g.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech convert text to audio
|
||||
@@ -367,8 +367,8 @@ func (g *GoogleModel) AudioSpeech(modelName *string, audioContent *string, apiCo
|
||||
return nil, fmt.Errorf("%s, no such method", g.Name())
|
||||
}
|
||||
|
||||
func (z *GoogleModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (g *GoogleModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", g.Name())
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
@@ -377,14 +377,14 @@ func (g *GoogleModel) OCRFile(modelName *string, content []byte, url *string, ap
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *GoogleModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (g *GoogleModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", g.Name())
|
||||
}
|
||||
|
||||
func (z *GoogleModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (g *GoogleModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", g.Name())
|
||||
}
|
||||
|
||||
func (z *GoogleModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (g *GoogleModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", g.Name())
|
||||
}
|
||||
|
||||
@@ -422,8 +422,8 @@ func (h *HuggingFaceModel) TranscribeAudio(modelName *string, file *string, apiC
|
||||
return nil, fmt.Errorf("%s, no such method", h.Name())
|
||||
}
|
||||
|
||||
func (z *HuggingFaceModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (h *HuggingFaceModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", h.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech convert text to audio
|
||||
@@ -431,8 +431,8 @@ func (h *HuggingFaceModel) AudioSpeech(modelName *string, audioContent *string,
|
||||
return nil, fmt.Errorf("%s, no such method", h.Name())
|
||||
}
|
||||
|
||||
func (z *HuggingFaceModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (h *HuggingFaceModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", h.Name())
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
@@ -441,8 +441,8 @@ func (h *HuggingFaceModel) OCRFile(modelName *string, content []byte, url *strin
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *HuggingFaceModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (h *HuggingFaceModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", h.Name())
|
||||
}
|
||||
|
||||
func (h *HuggingFaceModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
@@ -512,10 +512,10 @@ func (h *HuggingFaceModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (z *HuggingFaceModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (h *HuggingFaceModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", h.Name())
|
||||
}
|
||||
|
||||
func (z *HuggingFaceModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (h *HuggingFaceModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", h.Name())
|
||||
}
|
||||
|
||||
@@ -63,16 +63,16 @@ func NewHunyuanModel(baseURL map[string]string, urlSuffix URLSuffix) *HunyuanMod
|
||||
}
|
||||
}
|
||||
|
||||
func (a *HunyuanModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return NewHunyuanModel(baseURL, a.URLSuffix)
|
||||
func (h *HunyuanModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return NewHunyuanModel(baseURL, h.URLSuffix)
|
||||
}
|
||||
|
||||
func (a *HunyuanModel) Name() string {
|
||||
func (h *HunyuanModel) Name() string {
|
||||
return "hunyuan"
|
||||
}
|
||||
|
||||
func (a *HunyuanModel) baseURLForRegion(region string) (string, error) {
|
||||
base, ok := a.BaseURL[region]
|
||||
func (h *HunyuanModel) baseURLForRegion(region string) (string, error) {
|
||||
base, ok := h.BaseURL[region]
|
||||
if !ok || base == "" {
|
||||
return "", fmt.Errorf("hunyuan: no base URL configured for region %q", region)
|
||||
}
|
||||
@@ -83,7 +83,7 @@ func (a *HunyuanModel) baseURLForRegion(region string) (string, error) {
|
||||
// full response. Forwards documented OpenAI-shaped parameters when the
|
||||
// caller supplies them; reasoning_content is surfaced separately so the
|
||||
// visible Answer is never polluted by chain-of-thought.
|
||||
func (a *HunyuanModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
func (h *HunyuanModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
if apiConfig == nil || apiConfig.ApiKey == nil || *apiConfig.ApiKey == "" {
|
||||
return nil, fmt.Errorf("api key is required")
|
||||
}
|
||||
@@ -96,11 +96,11 @@ func (a *HunyuanModel) ChatWithMessages(modelName string, messages []Message, ap
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL, err := a.baseURLForRegion(region)
|
||||
baseURL, err := h.baseURLForRegion(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
url := fmt.Sprintf("%s/%s", baseURL, a.URLSuffix.Chat)
|
||||
url := fmt.Sprintf("%s/%s", baseURL, h.URLSuffix.Chat)
|
||||
|
||||
apiMessages := make([]map[string]interface{}, len(messages))
|
||||
for i, msg := range messages {
|
||||
@@ -146,7 +146,7 @@ func (a *HunyuanModel) ChatWithMessages(modelName string, messages []Message, ap
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := a.httpClient.Do(req)
|
||||
resp, err := h.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -204,7 +204,7 @@ func (a *HunyuanModel) ChatWithMessages(modelName string, messages []Message, ap
|
||||
// forwards each delta through the supplied sender. Reasoning chunks go
|
||||
// to the sender's second argument, content chunks to the first; the
|
||||
// stream is terminated by either `[DONE]` or a delta with finish_reason.
|
||||
func (a *HunyuanModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
func (h *HunyuanModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
if sender == nil {
|
||||
return fmt.Errorf("sender is required")
|
||||
}
|
||||
@@ -220,11 +220,11 @@ func (a *HunyuanModel) ChatStreamlyWithSender(modelName string, messages []Messa
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL, err := a.baseURLForRegion(region)
|
||||
baseURL, err := h.baseURLForRegion(region)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
url := fmt.Sprintf("%s/%s", baseURL, a.URLSuffix.Chat)
|
||||
url := fmt.Sprintf("%s/%s", baseURL, h.URLSuffix.Chat)
|
||||
|
||||
apiMessages := make([]map[string]interface{}, len(messages))
|
||||
for i, msg := range messages {
|
||||
@@ -275,7 +275,7 @@ func (a *HunyuanModel) ChatStreamlyWithSender(modelName string, messages []Messa
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := a.httpClient.Do(req)
|
||||
resp, err := h.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -364,7 +364,7 @@ func (a *HunyuanModel) ChatStreamlyWithSender(modelName string, messages []Messa
|
||||
// ListModels returns the model ids visible to the API key by calling
|
||||
// /v1/models. Used by Add-Provider's connection check and by the UI's
|
||||
// model picker.
|
||||
func (a *HunyuanModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
func (h *HunyuanModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
if apiConfig == nil || apiConfig.ApiKey == nil || *apiConfig.ApiKey == "" {
|
||||
return nil, fmt.Errorf("api key is required")
|
||||
}
|
||||
@@ -374,11 +374,11 @@ func (a *HunyuanModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL, err := a.baseURLForRegion(region)
|
||||
baseURL, err := h.baseURLForRegion(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
url := fmt.Sprintf("%s/%s", baseURL, a.URLSuffix.Models)
|
||||
url := fmt.Sprintf("%s/%s", baseURL, h.URLSuffix.Models)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), nonStreamCallTimeout)
|
||||
defer cancel()
|
||||
@@ -389,7 +389,7 @@ func (a *HunyuanModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
}
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := a.httpClient.Do(req)
|
||||
resp, err := h.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -431,12 +431,12 @@ func (a *HunyuanModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
// CheckConnection verifies the API key by calling ListModels. The /v1/models
|
||||
// endpoint is the documented lightweight way to validate credentials on
|
||||
// OpenAI-compatible gateways without burning chat-completion quota.
|
||||
func (a *HunyuanModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := a.ListModels(apiConfig)
|
||||
func (h *HunyuanModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := h.ListModels(apiConfig)
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *HunyuanModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
func (h *HunyuanModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
if len(texts) == 0 {
|
||||
return []EmbeddingData{}, nil
|
||||
}
|
||||
@@ -452,11 +452,11 @@ func (a *HunyuanModel) Embed(modelName *string, texts []string, apiConfig *APICo
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL, err := a.baseURLForRegion(region)
|
||||
baseURL, err := h.baseURLForRegion(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
url := fmt.Sprintf("%s/%s", baseURL, a.URLSuffix.Embedding)
|
||||
url := fmt.Sprintf("%s/%s", baseURL, h.URLSuffix.Embedding)
|
||||
|
||||
reqBody := map[string]interface{}{
|
||||
"model": *modelName,
|
||||
@@ -479,7 +479,7 @@ func (a *HunyuanModel) Embed(modelName *string, texts []string, apiConfig *APICo
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := a.httpClient.Do(req)
|
||||
resp, err := h.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -520,42 +520,42 @@ func (a *HunyuanModel) Embed(modelName *string, texts []string, apiConfig *APICo
|
||||
return embeddings, nil
|
||||
}
|
||||
|
||||
func (a *HunyuanModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
func (h *HunyuanModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", h.Name())
|
||||
}
|
||||
|
||||
func (a *HunyuanModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
func (h *HunyuanModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", h.Name())
|
||||
}
|
||||
|
||||
func (a *HunyuanModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
func (h *HunyuanModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", h.Name())
|
||||
}
|
||||
|
||||
func (a *HunyuanModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", a.Name())
|
||||
func (h *HunyuanModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", h.Name())
|
||||
}
|
||||
|
||||
func (a *HunyuanModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
func (h *HunyuanModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", h.Name())
|
||||
}
|
||||
|
||||
func (a *HunyuanModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", a.Name())
|
||||
func (h *HunyuanModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", h.Name())
|
||||
}
|
||||
|
||||
func (a *HunyuanModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
func (h *HunyuanModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", h.Name())
|
||||
}
|
||||
|
||||
func (a *HunyuanModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
func (h *HunyuanModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", h.Name())
|
||||
}
|
||||
|
||||
func (a *HunyuanModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
func (h *HunyuanModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", h.Name())
|
||||
}
|
||||
|
||||
func (a *HunyuanModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
func (h *HunyuanModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", h.Name())
|
||||
}
|
||||
|
||||
@@ -370,37 +370,37 @@ func (j *JinaModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
}
|
||||
|
||||
// TranscribeAudio transcribe audio
|
||||
func (z *JinaModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (j *JinaModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", j.Name())
|
||||
}
|
||||
|
||||
func (z *JinaModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (j *JinaModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", j.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech convert text to audio
|
||||
func (z *JinaModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (j *JinaModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", j.Name())
|
||||
}
|
||||
|
||||
func (z *JinaModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (j *JinaModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", j.Name())
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
func (z *JinaModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (j *JinaModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", j.Name())
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *JinaModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (j *JinaModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", j.Name())
|
||||
}
|
||||
|
||||
func (z *JinaModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (j *JinaModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", j.Name())
|
||||
}
|
||||
|
||||
func (z *JinaModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (j *JinaModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", j.Name())
|
||||
}
|
||||
|
||||
@@ -453,21 +453,21 @@ func (l *LmStudioModel) Rerank(modelName *string, query string, documents []stri
|
||||
}
|
||||
|
||||
// TranscribeAudio transcribe audio
|
||||
func (z *LmStudioModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (l *LmStudioModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", l.Name())
|
||||
}
|
||||
|
||||
func (z *LmStudioModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (l *LmStudioModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", l.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech convert text to audio
|
||||
func (z *LmStudioModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (l *LmStudioModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", l.Name())
|
||||
}
|
||||
|
||||
func (z *LmStudioModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (l *LmStudioModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", l.Name())
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
@@ -476,8 +476,8 @@ func (l *LmStudioModel) OCRFile(modelName *string, content []byte, url *string,
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *LmStudioModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (l *LmStudioModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", l.Name())
|
||||
}
|
||||
|
||||
// ListModels list supported models
|
||||
@@ -562,10 +562,10 @@ func (l *LmStudioModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (z *LmStudioModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (l *LmStudioModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", l.Name())
|
||||
}
|
||||
|
||||
func (z *LmStudioModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (l *LmStudioModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", l.Name())
|
||||
}
|
||||
|
||||
@@ -824,14 +824,14 @@ func (l *LocalAIModel) OCRFile(modelName *string, content []byte, url *string, a
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *LocalAIModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (l *LocalAIModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", l.Name())
|
||||
}
|
||||
|
||||
func (z *LocalAIModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (l *LocalAIModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", l.Name())
|
||||
}
|
||||
|
||||
func (z *LocalAIModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (l *LocalAIModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", l.Name())
|
||||
}
|
||||
|
||||
@@ -532,14 +532,14 @@ func (l *LongCatModel) OCRFile(modelName *string, content []byte, url *string, a
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *LongCatModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (l *LongCatModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", l.Name())
|
||||
}
|
||||
|
||||
func (z *LongCatModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (l *LongCatModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", l.Name())
|
||||
}
|
||||
|
||||
func (z *LongCatModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (l *LongCatModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", l.Name())
|
||||
}
|
||||
|
||||
@@ -53,16 +53,16 @@ func NewMinimaxModel(baseURL map[string]string, urlSuffix URLSuffix) *MinimaxMod
|
||||
}
|
||||
}
|
||||
|
||||
func (z *MinimaxModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
func (m *MinimaxModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (z *MinimaxModel) Name() string {
|
||||
func (m *MinimaxModel) Name() string {
|
||||
return "minimax"
|
||||
}
|
||||
|
||||
// ChatWithMessages sends multiple messages with roles and returns response
|
||||
func (z *MinimaxModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
func (m *MinimaxModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
if apiConfig == nil || apiConfig.ApiKey == nil || *apiConfig.ApiKey == "" {
|
||||
return nil, fmt.Errorf("api key is nil or empty")
|
||||
}
|
||||
@@ -75,7 +75,7 @@ func (z *MinimaxModel) ChatWithMessages(modelName string, messages []Message, ap
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", z.BaseURL[region], z.URLSuffix.Chat)
|
||||
url := fmt.Sprintf("%s/%s", m.BaseURL[region], m.URLSuffix.Chat)
|
||||
|
||||
// Convert messages to API format
|
||||
apiMessages := make([]map[string]interface{}, len(messages))
|
||||
@@ -145,7 +145,7 @@ func (z *MinimaxModel) ChatWithMessages(modelName string, messages []Message, ap
|
||||
req.Header.Add("Content-Type", "application/json")
|
||||
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := m.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -206,7 +206,7 @@ func (z *MinimaxModel) ChatWithMessages(modelName string, messages []Message, ap
|
||||
}
|
||||
|
||||
// ChatStreamlyWithSender sends messages and streams response via sender function (best performance, no channel)
|
||||
func (z *MinimaxModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, modelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
func (m *MinimaxModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, modelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
if len(messages) == 0 {
|
||||
return fmt.Errorf("messages is empty")
|
||||
}
|
||||
@@ -217,7 +217,7 @@ func (z *MinimaxModel) ChatStreamlyWithSender(modelName string, messages []Messa
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", z.BaseURL[region], z.URLSuffix.Chat)
|
||||
url := fmt.Sprintf("%s/%s", m.BaseURL[region], m.URLSuffix.Chat)
|
||||
|
||||
// Convert messages to API format
|
||||
apiMessages := make([]map[string]interface{}, len(messages))
|
||||
@@ -289,7 +289,7 @@ func (z *MinimaxModel) ChatStreamlyWithSender(modelName string, messages []Messa
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := m.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -371,17 +371,17 @@ func (z *MinimaxModel) ChatStreamlyWithSender(modelName string, messages []Messa
|
||||
}
|
||||
|
||||
// Embed embeds a list of texts into embeddings
|
||||
func (z *MinimaxModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
func (m *MinimaxModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
return nil, fmt.Errorf("not implemented")
|
||||
}
|
||||
|
||||
func (z *MinimaxModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
func (m *MinimaxModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
var region = "default"
|
||||
if apiConfig.Region != nil {
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", z.BaseURL[region], z.URLSuffix.Models)
|
||||
url := fmt.Sprintf("%s/%s", m.BaseURL[region], m.URLSuffix.Models)
|
||||
|
||||
// Build request body
|
||||
reqBody := map[string]interface{}{}
|
||||
@@ -402,7 +402,7 @@ func (z *MinimaxModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := m.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -434,17 +434,17 @@ func (z *MinimaxModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
return models, nil
|
||||
}
|
||||
|
||||
func (z *MinimaxModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (m *MinimaxModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
}
|
||||
|
||||
func (z *MinimaxModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
func (m *MinimaxModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
var region = "default"
|
||||
if apiConfig.Region != nil {
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", z.BaseURL[region], z.URLSuffix.Files)
|
||||
url := fmt.Sprintf("%s/%s", m.BaseURL[region], m.URLSuffix.Files)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), nonStreamCallTimeout)
|
||||
defer cancel()
|
||||
@@ -457,7 +457,7 @@ func (z *MinimaxModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := m.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -476,21 +476,21 @@ func (z *MinimaxModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
}
|
||||
|
||||
// Rerank calculates similarity scores between query and documents
|
||||
func (z *MinimaxModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
return nil, fmt.Errorf("%s, Rerank not implemented", z.Name())
|
||||
func (m *MinimaxModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
return nil, fmt.Errorf("%s, Rerank not implemented", m.Name())
|
||||
}
|
||||
|
||||
// TranscribeAudio transcribe audio
|
||||
func (z *MinimaxModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (m *MinimaxModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
}
|
||||
|
||||
func (z *MinimaxModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (m *MinimaxModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", m.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech convert text to audio
|
||||
func (z *MinimaxModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
func (m *MinimaxModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
if apiConfig == nil || apiConfig.ApiKey == nil || *apiConfig.ApiKey == "" {
|
||||
return nil, fmt.Errorf("MiniMax API key is missing")
|
||||
}
|
||||
@@ -503,7 +503,7 @@ func (z *MinimaxModel) AudioSpeech(modelName *string, audioContent *string, apiC
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", z.BaseURL[region], z.URLSuffix.TTS)
|
||||
url := fmt.Sprintf("%s/%s", m.BaseURL[region], m.URLSuffix.TTS)
|
||||
|
||||
reqBody := map[string]interface{}{
|
||||
"model": modelName,
|
||||
@@ -537,7 +537,7 @@ func (z *MinimaxModel) AudioSpeech(modelName *string, audioContent *string, apiC
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", strings.TrimSpace(*apiConfig.ApiKey)))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := m.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -581,7 +581,7 @@ func (z *MinimaxModel) AudioSpeech(modelName *string, audioContent *string, apiC
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (z *MinimaxModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
func (m *MinimaxModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
if apiConfig == nil || apiConfig.ApiKey == nil || *apiConfig.ApiKey == "" {
|
||||
return fmt.Errorf("MiniMax API key is missing")
|
||||
}
|
||||
@@ -594,11 +594,11 @@ func (z *MinimaxModel) AudioSpeechWithSender(modelName *string, audioContent *st
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL := strings.TrimSuffix(z.BaseURL[region], "/")
|
||||
baseURL := strings.TrimSuffix(m.BaseURL[region], "/")
|
||||
if baseURL == "" {
|
||||
baseURL = strings.TrimSuffix(z.BaseURL["default"], "/")
|
||||
baseURL = strings.TrimSuffix(m.BaseURL["default"], "/")
|
||||
}
|
||||
suffix := strings.TrimPrefix(z.URLSuffix.TTS, "/")
|
||||
suffix := strings.TrimPrefix(m.URLSuffix.TTS, "/")
|
||||
if suffix == "" {
|
||||
suffix = "v1/t2a_v2"
|
||||
}
|
||||
@@ -639,7 +639,7 @@ func (z *MinimaxModel) AudioSpeechWithSender(modelName *string, audioContent *st
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", strings.TrimSpace(*apiConfig.ApiKey)))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := m.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -704,14 +704,14 @@ func (m *MinimaxModel) OCRFile(modelName *string, content []byte, url *string, a
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *MinimaxModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (m *MinimaxModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
}
|
||||
|
||||
func (z *MinimaxModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (m *MinimaxModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
}
|
||||
|
||||
func (z *MinimaxModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (m *MinimaxModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
}
|
||||
|
||||
@@ -628,25 +628,25 @@ func (m *MistralModel) Rerank(modelName *string, query string, documents []strin
|
||||
}
|
||||
|
||||
// TranscribeAudio transcribe audio
|
||||
func (z *MistralModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (m *MistralModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
}
|
||||
|
||||
func (z *MistralModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (m *MistralModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", m.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech convert text to audio
|
||||
func (z *MistralModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (m *MistralModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
}
|
||||
|
||||
func (z *MistralModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (m *MistralModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", m.Name())
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
func (z *MistralModel) OCRFile(modelName *string, content []byte, urls *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
func (m *MistralModel) OCRFile(modelName *string, content []byte, urls *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
if (urls == nil || *urls == "") && (content == nil || len(content) == 0) {
|
||||
return nil, fmt.Errorf("file url or content is required")
|
||||
}
|
||||
@@ -656,7 +656,7 @@ func (z *MistralModel) OCRFile(modelName *string, content []byte, urls *string,
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", z.BaseURL[region], z.URLSuffix.OCR)
|
||||
url := fmt.Sprintf("%s/%s", m.BaseURL[region], m.URLSuffix.OCR)
|
||||
|
||||
var docURL string
|
||||
if urls != nil && *urls != "" {
|
||||
@@ -691,7 +691,7 @@ func (z *MistralModel) OCRFile(modelName *string, content []byte, urls *string,
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := m.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -730,15 +730,15 @@ func (z *MistralModel) OCRFile(modelName *string, content []byte, urls *string,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (z *MistralModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
func (m *MistralModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (z *MistralModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (m *MistralModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
}
|
||||
|
||||
func (z *MistralModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (m *MistralModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
}
|
||||
|
||||
@@ -52,15 +52,15 @@ func NewMoonshotModel(baseURL map[string]string, urlSuffix URLSuffix) *MoonshotM
|
||||
}
|
||||
}
|
||||
|
||||
func (z *MoonshotModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
func (m *MoonshotModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (z *MoonshotModel) Name() string {
|
||||
func (m *MoonshotModel) Name() string {
|
||||
return "moonshot"
|
||||
}
|
||||
|
||||
func (k *MoonshotModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
func (m *MoonshotModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
if len(messages) == 0 {
|
||||
return nil, fmt.Errorf("messages is empty")
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func (k *MoonshotModel) ChatWithMessages(modelName string, messages []Message, a
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", k.BaseURL[region], k.URLSuffix.Chat)
|
||||
url := fmt.Sprintf("%s/%s", m.BaseURL[region], m.URLSuffix.Chat)
|
||||
|
||||
// Convert messages to the format expected by API
|
||||
apiMessages := make([]map[string]interface{}, len(messages))
|
||||
@@ -141,7 +141,7 @@ func (k *MoonshotModel) ChatWithMessages(modelName string, messages []Message, a
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
}
|
||||
|
||||
resp, err := k.httpClient.Do(req)
|
||||
resp, err := m.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -203,7 +203,7 @@ func (k *MoonshotModel) ChatWithMessages(modelName string, messages []Message, a
|
||||
}
|
||||
|
||||
// ChatStreamlyWithSender sends messages and streams response via sender function (best performance, no channel)
|
||||
func (k *MoonshotModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
func (m *MoonshotModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
if len(messages) == 0 {
|
||||
return fmt.Errorf("messages is empty")
|
||||
}
|
||||
@@ -213,7 +213,7 @@ func (k *MoonshotModel) ChatStreamlyWithSender(modelName string, messages []Mess
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", k.BaseURL[region], k.URLSuffix.Chat)
|
||||
url := fmt.Sprintf("%s/%s", m.BaseURL[region], m.URLSuffix.Chat)
|
||||
|
||||
// Convert messages to API format
|
||||
apiMessages := make([]map[string]interface{}, len(messages))
|
||||
@@ -285,7 +285,7 @@ func (k *MoonshotModel) ChatStreamlyWithSender(modelName string, messages []Mess
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := k.httpClient.Do(req)
|
||||
resp, err := m.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -367,17 +367,17 @@ func (k *MoonshotModel) ChatStreamlyWithSender(modelName string, messages []Mess
|
||||
}
|
||||
|
||||
// Embed embeds a list of texts into embeddings
|
||||
func (z *MoonshotModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
func (m *MoonshotModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
return nil, fmt.Errorf("not implemented")
|
||||
}
|
||||
|
||||
func (z *MoonshotModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
func (m *MoonshotModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
var region = "default"
|
||||
if apiConfig.Region != nil && *apiConfig.Region != "" {
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", z.BaseURL[region], z.URLSuffix.Models)
|
||||
url := fmt.Sprintf("%s/%s", m.BaseURL[region], m.URLSuffix.Models)
|
||||
|
||||
// Build request body
|
||||
reqBody := map[string]interface{}{}
|
||||
@@ -398,7 +398,7 @@ func (z *MoonshotModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := m.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -430,13 +430,13 @@ func (z *MoonshotModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
return models, nil
|
||||
}
|
||||
|
||||
func (z *MoonshotModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
func (m *MoonshotModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
var region = "default"
|
||||
if apiConfig.Region != nil && *apiConfig.Region != "" {
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", z.BaseURL[region], z.URLSuffix.Balance)
|
||||
url := fmt.Sprintf("%s/%s", m.BaseURL[region], m.URLSuffix.Balance)
|
||||
|
||||
// Build request body
|
||||
reqBody := map[string]interface{}{}
|
||||
@@ -457,7 +457,7 @@ func (z *MoonshotModel) Balance(apiConfig *APIConfig) (map[string]interface{}, e
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := m.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -489,8 +489,8 @@ func (z *MoonshotModel) Balance(apiConfig *APIConfig) (map[string]interface{}, e
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (z *MoonshotModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := z.ListModels(apiConfig)
|
||||
func (m *MoonshotModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := m.ListModels(apiConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -498,26 +498,26 @@ func (z *MoonshotModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
}
|
||||
|
||||
// Rerank calculates similarity scores between query and documents
|
||||
func (z *MoonshotModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
return nil, fmt.Errorf("%s, Rerank not implemented", z.Name())
|
||||
func (m *MoonshotModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
return nil, fmt.Errorf("%s, Rerank not implemented", m.Name())
|
||||
}
|
||||
|
||||
// TranscribeAudio transcribe audio
|
||||
func (z *MoonshotModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (m *MoonshotModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
}
|
||||
|
||||
func (z *MoonshotModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (m *MoonshotModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", m.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech convert text to audio
|
||||
func (z *MoonshotModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (m *MoonshotModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
}
|
||||
|
||||
func (z *MoonshotModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (m *MoonshotModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", m.Name())
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
@@ -526,14 +526,14 @@ func (m *MoonshotModel) OCRFile(modelName *string, content []byte, url *string,
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *MoonshotModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (m *MoonshotModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
}
|
||||
|
||||
func (z *MoonshotModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (m *MoonshotModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
}
|
||||
|
||||
func (z *MoonshotModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (m *MoonshotModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
}
|
||||
|
||||
@@ -78,27 +78,27 @@ func NewN1NModel(baseURL map[string]string, urlSuffix URLSuffix) *N1NModel {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *N1NModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return NewN1NModel(baseURL, m.URLSuffix)
|
||||
func (n *N1NModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return NewN1NModel(baseURL, n.URLSuffix)
|
||||
}
|
||||
|
||||
func (m *N1NModel) Name() string {
|
||||
func (n *N1NModel) Name() string {
|
||||
return "n1n"
|
||||
}
|
||||
|
||||
// baseURLForRegion returns the base URL for the given region, trimmed
|
||||
// of any trailing slash so callers can append a suffix without
|
||||
// producing "//" in the path.
|
||||
func (m *N1NModel) baseURLForRegion(region string) (string, error) {
|
||||
base, ok := m.BaseURL[region]
|
||||
func (n *N1NModel) baseURLForRegion(region string) (string, error) {
|
||||
base, ok := n.BaseURL[region]
|
||||
if !ok || base == "" {
|
||||
return "", fmt.Errorf("n1n: no base URL configured for region %q", region)
|
||||
}
|
||||
return strings.TrimRight(base, "/"), nil
|
||||
}
|
||||
|
||||
func (m *N1NModel) endpointURL(region, suffix string) (string, error) {
|
||||
baseURL, err := m.baseURLForRegion(region)
|
||||
func (n *N1NModel) endpointURL(region, suffix string) (string, error) {
|
||||
baseURL, err := n.baseURLForRegion(region)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -220,7 +220,7 @@ type n1nChatResponse struct {
|
||||
|
||||
// ChatWithMessages sends a single, non-streaming chat completion
|
||||
// against n1n.ai's /v1/chat/completions endpoint.
|
||||
func (m *N1NModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
func (n *N1NModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
apiKey, err := n1nValidateAPIKey(apiConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -232,7 +232,7 @@ func (m *N1NModel) ChatWithMessages(modelName string, messages []Message, apiCon
|
||||
return nil, fmt.Errorf("messages is empty")
|
||||
}
|
||||
|
||||
endpoint, err := m.endpointURL(n1nRegion(apiConfig), m.URLSuffix.Chat)
|
||||
endpoint, err := n.endpointURL(n1nRegion(apiConfig), n.URLSuffix.Chat)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -250,7 +250,7 @@ func (m *N1NModel) ChatWithMessages(modelName string, messages []Message, apiCon
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := m.httpClient.Do(req)
|
||||
resp, err := n.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -295,7 +295,7 @@ func (m *N1NModel) ChatWithMessages(modelName string, messages []Message, apiCon
|
||||
// SSE stream uses the standard OpenAI shape: "data:" lines carrying
|
||||
// JSON events with delta.content (and delta.reasoning_content for
|
||||
// reasoning-capable models), terminated by a "[DONE]" line.
|
||||
func (m *N1NModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
func (n *N1NModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
if sender == nil {
|
||||
return fmt.Errorf("sender is required")
|
||||
}
|
||||
@@ -310,7 +310,7 @@ func (m *N1NModel) ChatStreamlyWithSender(modelName string, messages []Message,
|
||||
return err
|
||||
}
|
||||
|
||||
endpoint, err := m.endpointURL(n1nRegion(apiConfig), m.URLSuffix.Chat)
|
||||
endpoint, err := n.endpointURL(n1nRegion(apiConfig), n.URLSuffix.Chat)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -333,7 +333,7 @@ func (m *N1NModel) ChatStreamlyWithSender(modelName string, messages []Message,
|
||||
return err
|
||||
}
|
||||
|
||||
resp, err := m.httpClient.Do(req)
|
||||
resp, err := n.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -425,7 +425,7 @@ type n1nEmbeddingRequest struct {
|
||||
// Embed turns a list of texts into embedding vectors using the
|
||||
// n1n.ai /v1/embeddings endpoint. Output is one vector per input, in
|
||||
// the same order the inputs were given.
|
||||
func (m *N1NModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
func (n *N1NModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
if len(texts) == 0 {
|
||||
return []EmbeddingData{}, nil
|
||||
}
|
||||
@@ -437,7 +437,7 @@ func (m *N1NModel) Embed(modelName *string, texts []string, apiConfig *APIConfig
|
||||
return nil, fmt.Errorf("model name is required")
|
||||
}
|
||||
|
||||
endpoint, err := m.endpointURL(n1nRegion(apiConfig), m.URLSuffix.Embedding)
|
||||
endpoint, err := n.endpointURL(n1nRegion(apiConfig), n.URLSuffix.Embedding)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -458,7 +458,7 @@ func (m *N1NModel) Embed(modelName *string, texts []string, apiConfig *APIConfig
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := m.httpClient.Do(req)
|
||||
resp, err := n.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -523,7 +523,7 @@ type n1nRerankRequest struct {
|
||||
|
||||
// Rerank scores a query against a list of documents using
|
||||
// n1n.ai's /v1/rerank endpoint (Cohere-shaped response).
|
||||
func (m *N1NModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
func (n *N1NModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
if len(documents) == 0 {
|
||||
return &RerankResponse{}, nil
|
||||
}
|
||||
@@ -535,7 +535,7 @@ func (m *N1NModel) Rerank(modelName *string, query string, documents []string, a
|
||||
return nil, fmt.Errorf("model name is required")
|
||||
}
|
||||
|
||||
endpoint, err := m.endpointURL(n1nRegion(apiConfig), m.URLSuffix.Rerank)
|
||||
endpoint, err := n.endpointURL(n1nRegion(apiConfig), n.URLSuffix.Rerank)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -557,7 +557,7 @@ func (m *N1NModel) Rerank(modelName *string, query string, documents []string, a
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := m.httpClient.Do(req)
|
||||
resp, err := n.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -606,13 +606,13 @@ type n1nModelCatalogResponse struct {
|
||||
// GET /v1/models. The shipped catalog in conf/models/n1n.json is a
|
||||
// representative subset; this method surfaces the full upstream list
|
||||
// (hundreds of models routed through the aggregator).
|
||||
func (m *N1NModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
func (n *N1NModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
apiKey, err := n1nValidateAPIKey(apiConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
endpoint, err := m.endpointURL(n1nRegion(apiConfig), m.URLSuffix.Models)
|
||||
endpoint, err := n.endpointURL(n1nRegion(apiConfig), n.URLSuffix.Models)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -625,7 +625,7 @@ func (m *N1NModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := m.httpClient.Do(req)
|
||||
resp, err := n.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -656,8 +656,8 @@ func (m *N1NModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
// CheckConnection verifies the API key by querying the documented
|
||||
// /v1/models endpoint — the cheapest auth check on the documented
|
||||
// surface, with no per-call charge against tenant quota.
|
||||
func (m *N1NModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := m.ListModels(apiConfig)
|
||||
func (n *N1NModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := n.ListModels(apiConfig)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -665,46 +665,46 @@ func (m *N1NModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
// quota are available only via the web console at
|
||||
// https://api.n1n.ai/console; the public API surface does not
|
||||
// publish them.
|
||||
func (m *N1NModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (n *N1NModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", n.Name())
|
||||
}
|
||||
|
||||
// TranscribeAudio: n1n.ai exposes /v1/audio/transcriptions but the
|
||||
// driver does not currently implement the multipart upload flow.
|
||||
func (m *N1NModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (n *N1NModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", n.Name())
|
||||
}
|
||||
|
||||
func (m *N1NModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", m.Name())
|
||||
func (n *N1NModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", n.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech: n1n.ai exposes /v1/audio/speech but the driver does
|
||||
// not currently implement the binary audio response handling.
|
||||
func (m *N1NModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (n *N1NModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", n.Name())
|
||||
}
|
||||
|
||||
func (m *N1NModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", m.Name())
|
||||
func (n *N1NModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", n.Name())
|
||||
}
|
||||
|
||||
// OCRFile is not exposed by the n1n.ai API.
|
||||
func (m *N1NModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (n *N1NModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", n.Name())
|
||||
}
|
||||
|
||||
// ParseFile is not exposed by the n1n.ai API.
|
||||
func (m *N1NModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (n *N1NModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", n.Name())
|
||||
}
|
||||
|
||||
// ListTasks: n1n.ai has /v1/contents/generations/tasks for async
|
||||
// image/video jobs, but that surface is not modeled by this driver.
|
||||
func (m *N1NModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (n *N1NModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", n.Name())
|
||||
}
|
||||
|
||||
func (m *N1NModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (n *N1NModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", n.Name())
|
||||
}
|
||||
|
||||
@@ -940,14 +940,14 @@ func (n *NovitaModel) OCRFile(modelName *string, content []byte, url *string, ap
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *NovitaModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (n *NovitaModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", n.Name())
|
||||
}
|
||||
|
||||
func (z *NovitaModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (n *NovitaModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", n.Name())
|
||||
}
|
||||
|
||||
func (z *NovitaModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (n *NovitaModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", n.Name())
|
||||
}
|
||||
|
||||
@@ -562,8 +562,8 @@ func (n *NvidiaModel) TranscribeAudio(modelName *string, file *string, apiConfig
|
||||
return nil, fmt.Errorf("%s, no such method", n.Name())
|
||||
}
|
||||
|
||||
func (z *NvidiaModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (n *NvidiaModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", n.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech convert text to audio
|
||||
@@ -571,18 +571,18 @@ func (n *NvidiaModel) AudioSpeech(modelName *string, audioContent *string, apiCo
|
||||
return nil, fmt.Errorf("%s, no such method", n.Name())
|
||||
}
|
||||
|
||||
func (z *NvidiaModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (n *NvidiaModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", n.Name())
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
func (m *NvidiaModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (n *NvidiaModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", n.Name())
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *NvidiaModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (n *NvidiaModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", n.Name())
|
||||
}
|
||||
|
||||
// ListModels calls /v1/models on the configured NVIDIA NIM base URL
|
||||
@@ -671,10 +671,10 @@ func (n NvidiaModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (z *NvidiaModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (n *NvidiaModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", n.Name())
|
||||
}
|
||||
|
||||
func (z *NvidiaModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (n *NvidiaModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", n.Name())
|
||||
}
|
||||
|
||||
@@ -431,8 +431,8 @@ func (o *OllamaModel) TranscribeAudio(modelName *string, file *string, apiConfig
|
||||
return nil, fmt.Errorf("%s, no such method", o.Name())
|
||||
}
|
||||
|
||||
func (z *OllamaModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (o *OllamaModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", o.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech convert text to audio
|
||||
@@ -440,18 +440,18 @@ func (o *OllamaModel) AudioSpeech(modelName *string, audioContent *string, apiCo
|
||||
return nil, fmt.Errorf("%s, no such method", o.Name())
|
||||
}
|
||||
|
||||
func (z *OllamaModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (o *OllamaModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", o.Name())
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
func (m *OllamaModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (o *OllamaModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", o.Name())
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *OllamaModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (o *OllamaModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", o.Name())
|
||||
}
|
||||
|
||||
func (o *OllamaModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
@@ -529,10 +529,10 @@ func (o *OllamaModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (z *OllamaModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (o *OllamaModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", o.Name())
|
||||
}
|
||||
|
||||
func (z *OllamaModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (o *OllamaModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", o.Name())
|
||||
}
|
||||
|
||||
@@ -74,11 +74,11 @@ func NewOpenAIModel(baseURL map[string]string, urlSuffix URLSuffix) *OpenAIModel
|
||||
}
|
||||
}
|
||||
|
||||
func (z *OpenAIModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return NewOpenAIModel(baseURL, z.URLSuffix)
|
||||
func (o *OpenAIModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return NewOpenAIModel(baseURL, o.URLSuffix)
|
||||
}
|
||||
|
||||
func (z *OpenAIModel) Name() string {
|
||||
func (o *OpenAIModel) Name() string {
|
||||
return "openai"
|
||||
}
|
||||
|
||||
@@ -86,8 +86,8 @@ func (z *OpenAIModel) Name() string {
|
||||
// error if no entry exists. This makes a misconfigured region fail
|
||||
// fast with a clear message, instead of silently producing a relative
|
||||
// URL that the HTTP transport then rejects.
|
||||
func (z *OpenAIModel) baseURLForRegion(region string) (string, error) {
|
||||
base, ok := z.BaseURL[region]
|
||||
func (o *OpenAIModel) baseURLForRegion(region string) (string, error) {
|
||||
base, ok := o.BaseURL[region]
|
||||
if !ok || base == "" {
|
||||
return "", fmt.Errorf("openai: no base URL configured for region %q", region)
|
||||
}
|
||||
@@ -95,7 +95,7 @@ func (z *OpenAIModel) baseURLForRegion(region string) (string, error) {
|
||||
}
|
||||
|
||||
// ChatWithMessages sends multiple messages with roles and returns the response
|
||||
func (z *OpenAIModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
func (o *OpenAIModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
if apiConfig == nil || apiConfig.ApiKey == nil || *apiConfig.ApiKey == "" {
|
||||
return nil, fmt.Errorf("api key is required")
|
||||
}
|
||||
@@ -109,11 +109,11 @@ func (z *OpenAIModel) ChatWithMessages(modelName string, messages []Message, api
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL, err := z.baseURLForRegion(region)
|
||||
baseURL, err := o.baseURLForRegion(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
url := fmt.Sprintf("%s/%s", baseURL, z.URLSuffix.Chat)
|
||||
url := fmt.Sprintf("%s/%s", baseURL, o.URLSuffix.Chat)
|
||||
|
||||
// Convert messages to the format expected by the API
|
||||
apiMessages := make([]map[string]interface{}, len(messages))
|
||||
@@ -169,7 +169,7 @@ func (z *OpenAIModel) ChatWithMessages(modelName string, messages []Message, api
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := o.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -230,7 +230,7 @@ func (z *OpenAIModel) ChatWithMessages(modelName string, messages []Message, api
|
||||
|
||||
// ChatStreamlyWithSender sends messages and streams the response via the
|
||||
// sender function. Used for streaming chat responses with no extra channel.
|
||||
func (z *OpenAIModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
func (o *OpenAIModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
if len(messages) == 0 {
|
||||
return fmt.Errorf("messages is empty")
|
||||
}
|
||||
@@ -244,11 +244,11 @@ func (z *OpenAIModel) ChatStreamlyWithSender(modelName string, messages []Messag
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL, err := z.baseURLForRegion(region)
|
||||
baseURL, err := o.baseURLForRegion(region)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
url := fmt.Sprintf("%s/%s", baseURL, z.URLSuffix.Chat)
|
||||
url := fmt.Sprintf("%s/%s", baseURL, o.URLSuffix.Chat)
|
||||
|
||||
// Convert messages to API format (supports multimodal content)
|
||||
apiMessages := make([]map[string]interface{}, len(messages))
|
||||
@@ -311,7 +311,7 @@ func (z *OpenAIModel) ChatStreamlyWithSender(modelName string, messages []Messag
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := o.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -430,7 +430,7 @@ type openaiUsage struct {
|
||||
// OpenAI /v1/embeddings endpoint (e.g. text-embedding-3-small,
|
||||
// text-embedding-3-large, text-embedding-ada-002). The output has
|
||||
// one vector per input, in the same order the inputs were given.
|
||||
func (z *OpenAIModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
func (o *OpenAIModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
if len(texts) == 0 {
|
||||
return []EmbeddingData{}, nil
|
||||
}
|
||||
@@ -448,11 +448,11 @@ func (z *OpenAIModel) Embed(modelName *string, texts []string, apiConfig *APICon
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL, err := z.baseURLForRegion(region)
|
||||
baseURL, err := o.baseURLForRegion(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
url := fmt.Sprintf("%s/%s", baseURL, z.URLSuffix.Embedding)
|
||||
url := fmt.Sprintf("%s/%s", baseURL, o.URLSuffix.Embedding)
|
||||
|
||||
reqBody := map[string]interface{}{
|
||||
"model": *modelName,
|
||||
@@ -478,7 +478,7 @@ func (z *OpenAIModel) Embed(modelName *string, texts []string, apiConfig *APICon
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := o.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -510,7 +510,7 @@ func (z *OpenAIModel) Embed(modelName *string, texts []string, apiConfig *APICon
|
||||
}
|
||||
|
||||
// ListModels returns the list of model ids visible to the API key.
|
||||
func (z *OpenAIModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
func (o *OpenAIModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
if apiConfig == nil || apiConfig.ApiKey == nil || *apiConfig.ApiKey == "" {
|
||||
return nil, fmt.Errorf("api key is required")
|
||||
}
|
||||
@@ -520,11 +520,11 @@ func (z *OpenAIModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL, err := z.baseURLForRegion(region)
|
||||
baseURL, err := o.baseURLForRegion(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
url := fmt.Sprintf("%s/%s", baseURL, z.URLSuffix.Models)
|
||||
url := fmt.Sprintf("%s/%s", baseURL, o.URLSuffix.Models)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), nonStreamCallTimeout)
|
||||
defer cancel()
|
||||
@@ -537,7 +537,7 @@ func (z *OpenAIModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
// GET has no body, so Content-Type is not needed.
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := o.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -580,13 +580,13 @@ func (z *OpenAIModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
}
|
||||
|
||||
// Balance is not exposed by the OpenAI API, so this returns "no such method".
|
||||
func (z *OpenAIModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
func (o *OpenAIModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
return nil, fmt.Errorf("no such method")
|
||||
}
|
||||
|
||||
// CheckConnection runs a lightweight ListModels call to verify the API key.
|
||||
func (z *OpenAIModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := z.ListModels(apiConfig)
|
||||
func (o *OpenAIModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := o.ListModels(apiConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -595,8 +595,8 @@ func (z *OpenAIModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
|
||||
// Rerank calculates similarity scores between query and documents. OpenAI does
|
||||
// not expose a rerank API, so this is left unimplemented.
|
||||
func (z *OpenAIModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
return nil, fmt.Errorf("%s, Rerank not implemented", z.Name())
|
||||
func (o *OpenAIModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
return nil, fmt.Errorf("%s, Rerank not implemented", o.Name())
|
||||
}
|
||||
|
||||
// TranscribeAudio transcribe audio
|
||||
@@ -629,18 +629,18 @@ func (o *OpenAIModel) TranscribeAudio(modelName *string, file *string, apiConfig
|
||||
return decodeOpenAIASRResponse(respBody, responseFormat)
|
||||
}
|
||||
|
||||
func (z *OpenAIModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
func (o *OpenAIModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
if sender == nil {
|
||||
return fmt.Errorf("sender is required")
|
||||
}
|
||||
|
||||
req, responseFormat, err := z.newOpenAIASRRequest(context.Background(), modelName, file, apiConfig, asrConfig, true)
|
||||
req, responseFormat, err := o.newOpenAIASRRequest(context.Background(), modelName, file, apiConfig, asrConfig, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req.Header.Set("Accept", "text/event-stream")
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := o.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -764,12 +764,12 @@ func (o *OpenAIModel) AudioSpeech(modelName *string, audioContent *string, apiCo
|
||||
return &TTSResponse{Audio: body}, nil
|
||||
}
|
||||
|
||||
func (z *OpenAIModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
func (o *OpenAIModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
if sender == nil {
|
||||
return fmt.Errorf("sender is required")
|
||||
}
|
||||
|
||||
req, streamFormat, err := z.newOpenAITTSRequest(context.Background(), modelName, audioContent, apiConfig, ttsConfig, true)
|
||||
req, streamFormat, err := o.newOpenAITTSRequest(context.Background(), modelName, audioContent, apiConfig, ttsConfig, true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -777,7 +777,7 @@ func (z *OpenAIModel) AudioSpeechWithSender(modelName *string, audioContent *str
|
||||
req.Header.Set("Accept", "text/event-stream")
|
||||
}
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := o.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -1035,19 +1035,19 @@ func writeOpenAIMultipartField(writer *multipart.Writer, key string, value inter
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
func (m *OpenAIModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (o *OpenAIModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", o.Name())
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *OpenAIModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (o *OpenAIModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", o.Name())
|
||||
}
|
||||
|
||||
func (z *OpenAIModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (o *OpenAIModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", o.Name())
|
||||
}
|
||||
|
||||
func (z *OpenAIModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (o *OpenAIModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", o.Name())
|
||||
}
|
||||
|
||||
@@ -648,8 +648,8 @@ func (o *OpenRouterModel) TranscribeAudio(modelName *string, file *string, apiCo
|
||||
return &ASRResponse{Text: result.Text}, nil
|
||||
}
|
||||
|
||||
func (z *OpenRouterModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (o *OpenRouterModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", o.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech convert text to audio
|
||||
@@ -717,18 +717,18 @@ func (o *OpenRouterModel) AudioSpeech(modelName *string, audioContent *string, a
|
||||
return &TTSResponse{Audio: body}, nil
|
||||
}
|
||||
|
||||
func (z *OpenRouterModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (o *OpenRouterModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", o.Name())
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
func (m *OpenRouterModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (o *OpenRouterModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", o.Name())
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *OpenRouterModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (o *OpenRouterModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", o.Name())
|
||||
}
|
||||
|
||||
func (o *OpenRouterModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
@@ -850,10 +850,10 @@ func (o *OpenRouterModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (z *OpenRouterModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (o *OpenRouterModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", o.Name())
|
||||
}
|
||||
|
||||
func (z *OpenRouterModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (o *OpenRouterModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", o.Name())
|
||||
}
|
||||
|
||||
@@ -56,11 +56,11 @@ func NewSiliconflowModel(baseURL map[string]string, urlSuffix URLSuffix) *Silico
|
||||
}
|
||||
}
|
||||
|
||||
func (z *SiliconflowModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
func (s *SiliconflowModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (z *SiliconflowModel) Name() string {
|
||||
func (s *SiliconflowModel) Name() string {
|
||||
return "siliconflow"
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ type SiliconflowRerankRequest struct {
|
||||
}
|
||||
|
||||
// ChatWithMessages sends multiple messages with roles and returns response
|
||||
func (z *SiliconflowModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
func (s *SiliconflowModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
if apiConfig == nil || apiConfig.ApiKey == nil || *apiConfig.ApiKey == "" {
|
||||
return nil, fmt.Errorf("api key is nil or empty")
|
||||
}
|
||||
@@ -89,7 +89,7 @@ func (z *SiliconflowModel) ChatWithMessages(modelName string, messages []Message
|
||||
if apiConfig.Region != nil && *apiConfig.Region != "" {
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
url := fmt.Sprintf("%s/%s", z.BaseURL[region], z.URLSuffix.Chat)
|
||||
url := fmt.Sprintf("%s/%s", s.BaseURL[region], s.URLSuffix.Chat)
|
||||
|
||||
// Convert messages to the format expected by API
|
||||
apiMessages := make([]map[string]interface{}, len(messages))
|
||||
@@ -146,7 +146,7 @@ func (z *SiliconflowModel) ChatWithMessages(modelName string, messages []Message
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := s.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -214,7 +214,7 @@ func (z *SiliconflowModel) ChatWithMessages(modelName string, messages []Message
|
||||
}
|
||||
|
||||
// ChatStreamlyWithSender sends messages and streams response via sender function (best performance, no channel)
|
||||
func (z *SiliconflowModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
func (s *SiliconflowModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
if len(messages) == 0 {
|
||||
return fmt.Errorf("messages is empty")
|
||||
}
|
||||
@@ -224,7 +224,7 @@ func (z *SiliconflowModel) ChatStreamlyWithSender(modelName string, messages []M
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", z.BaseURL[region], z.URLSuffix.Chat)
|
||||
url := fmt.Sprintf("%s/%s", s.BaseURL[region], s.URLSuffix.Chat)
|
||||
|
||||
// Convert messages to API format
|
||||
apiMessages := make([]map[string]interface{}, len(messages))
|
||||
@@ -297,7 +297,7 @@ func (z *SiliconflowModel) ChatStreamlyWithSender(modelName string, messages []M
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := s.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -481,13 +481,13 @@ func (s *SiliconflowModel) Embed(modelName *string, texts []string, apiConfig *A
|
||||
return embeddings, nil
|
||||
}
|
||||
|
||||
func (z *SiliconflowModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
func (s *SiliconflowModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
var region = "default"
|
||||
if apiConfig.Region != nil && *apiConfig.Region != "" {
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", z.BaseURL[region], z.URLSuffix.Models)
|
||||
url := fmt.Sprintf("%s/%s", s.BaseURL[region], s.URLSuffix.Models)
|
||||
|
||||
// Build request body
|
||||
reqBody := map[string]interface{}{}
|
||||
@@ -508,7 +508,7 @@ func (z *SiliconflowModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := s.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -551,7 +551,7 @@ type siliconflowBalanceResponse struct {
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
func (z *SiliconflowModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
func (s *SiliconflowModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
if apiConfig == nil || apiConfig.ApiKey == nil || *apiConfig.ApiKey == "" {
|
||||
return nil, fmt.Errorf("api key is required")
|
||||
}
|
||||
@@ -561,9 +561,9 @@ func (z *SiliconflowModel) Balance(apiConfig *APIConfig) (map[string]interface{}
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL := z.BaseURL["default"]
|
||||
baseURL := s.BaseURL["default"]
|
||||
if region != "default" {
|
||||
if regional, ok := z.BaseURL[region]; ok && regional != "" {
|
||||
if regional, ok := s.BaseURL[region]; ok && regional != "" {
|
||||
baseURL = regional
|
||||
}
|
||||
}
|
||||
@@ -571,7 +571,7 @@ func (z *SiliconflowModel) Balance(apiConfig *APIConfig) (map[string]interface{}
|
||||
return nil, fmt.Errorf("siliconflow: no base URL configured for default region")
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", strings.TrimSuffix(baseURL, "/"), z.URLSuffix.Balance)
|
||||
url := fmt.Sprintf("%s/%s", strings.TrimSuffix(baseURL, "/"), s.URLSuffix.Balance)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), nonStreamCallTimeout)
|
||||
defer cancel()
|
||||
@@ -583,7 +583,7 @@ func (z *SiliconflowModel) Balance(apiConfig *APIConfig) (map[string]interface{}
|
||||
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := s.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -630,8 +630,8 @@ func (z *SiliconflowModel) Balance(apiConfig *APIConfig) (map[string]interface{}
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (z *SiliconflowModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := z.ListModels(apiConfig)
|
||||
func (s *SiliconflowModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := s.ListModels(apiConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -744,7 +744,7 @@ func (s *SiliconflowModel) Rerank(modelName *string, query string, documents []s
|
||||
}
|
||||
|
||||
// TranscribeAudio transcribe audio
|
||||
func (o *SiliconflowModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
func (s *SiliconflowModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
if file == nil || *file == "" {
|
||||
return nil, fmt.Errorf("file is missing")
|
||||
}
|
||||
@@ -754,7 +754,7 @@ func (o *SiliconflowModel) TranscribeAudio(modelName *string, file *string, apiC
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", o.BaseURL[region], o.URLSuffix.ASR)
|
||||
url := fmt.Sprintf("%s/%s", s.BaseURL[region], s.URLSuffix.ASR)
|
||||
|
||||
// multipart body
|
||||
var body bytes.Buffer
|
||||
@@ -833,7 +833,7 @@ func (o *SiliconflowModel) TranscribeAudio(modelName *string, file *string, apiC
|
||||
req.Header.Set("Accept", "application/json")
|
||||
|
||||
// send request
|
||||
resp, err := o.httpClient.Do(req)
|
||||
resp, err := s.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -860,12 +860,12 @@ func (o *SiliconflowModel) TranscribeAudio(modelName *string, file *string, apiC
|
||||
return &ASRResponse{Text: result.Text}, nil
|
||||
}
|
||||
|
||||
func (z *SiliconflowModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (s *SiliconflowModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", s.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech convert text to audio
|
||||
func (o *SiliconflowModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
func (s *SiliconflowModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
if audioContent == nil || *audioContent == "" {
|
||||
return nil, fmt.Errorf("audio content is empty")
|
||||
}
|
||||
@@ -875,7 +875,7 @@ func (o *SiliconflowModel) AudioSpeech(modelName *string, audioContent *string,
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", o.BaseURL[region], o.URLSuffix.TTS)
|
||||
url := fmt.Sprintf("%s/%s", s.BaseURL[region], s.URLSuffix.TTS)
|
||||
|
||||
reqBody := map[string]interface{}{
|
||||
"model": *modelName,
|
||||
@@ -908,7 +908,7 @@ func (o *SiliconflowModel) AudioSpeech(modelName *string, audioContent *string,
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := o.httpClient.Do(req)
|
||||
resp, err := s.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -926,7 +926,7 @@ func (o *SiliconflowModel) AudioSpeech(modelName *string, audioContent *string,
|
||||
return &TTSResponse{Audio: body}, nil
|
||||
}
|
||||
|
||||
func (z *SiliconflowModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
func (s *SiliconflowModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
if apiConfig == nil || apiConfig.ApiKey == nil || *apiConfig.ApiKey == "" {
|
||||
return fmt.Errorf("SiliconFlow API key is missing")
|
||||
}
|
||||
@@ -940,7 +940,7 @@ func (z *SiliconflowModel) AudioSpeechWithSender(modelName *string, audioContent
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", z.BaseURL[region], z.URLSuffix.TTS)
|
||||
url := fmt.Sprintf("%s/%s", s.BaseURL[region], s.URLSuffix.TTS)
|
||||
|
||||
reqBody := map[string]interface{}{
|
||||
"model": *modelName,
|
||||
@@ -973,7 +973,7 @@ func (z *SiliconflowModel) AudioSpeechWithSender(modelName *string, audioContent
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := s.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -1007,19 +1007,19 @@ func (z *SiliconflowModel) AudioSpeechWithSender(modelName *string, audioContent
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
func (m *SiliconflowModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (s *SiliconflowModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", s.Name())
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *SiliconflowModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (s *SiliconflowModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", s.Name())
|
||||
}
|
||||
|
||||
func (z *SiliconflowModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (s *SiliconflowModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", s.Name())
|
||||
}
|
||||
|
||||
func (z *SiliconflowModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (s *SiliconflowModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", s.Name())
|
||||
}
|
||||
|
||||
@@ -643,19 +643,19 @@ func (s *StepFunModel) AudioSpeechWithSender(modelName *string, audioContent *st
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
func (z *StepFunModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (s *StepFunModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", s.Name())
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *StepFunModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (s *StepFunModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", s.Name())
|
||||
}
|
||||
|
||||
func (z *StepFunModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (s *StepFunModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", s.Name())
|
||||
}
|
||||
|
||||
func (z *StepFunModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (s *StepFunModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", s.Name())
|
||||
}
|
||||
|
||||
@@ -72,16 +72,16 @@ func NewTokenPonyModel(baseURL map[string]string, urlSuffix URLSuffix) *TokenPon
|
||||
}
|
||||
}
|
||||
|
||||
func (a *TokenPonyModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return NewTokenPonyModel(baseURL, a.URLSuffix)
|
||||
func (t *TokenPonyModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return NewTokenPonyModel(baseURL, t.URLSuffix)
|
||||
}
|
||||
|
||||
func (a *TokenPonyModel) Name() string {
|
||||
func (t *TokenPonyModel) Name() string {
|
||||
return "tokenpony"
|
||||
}
|
||||
|
||||
func (a *TokenPonyModel) baseURLForRegion(region string) (string, error) {
|
||||
base, ok := a.BaseURL[region]
|
||||
func (t *TokenPonyModel) baseURLForRegion(region string) (string, error) {
|
||||
base, ok := t.BaseURL[region]
|
||||
if !ok || base == "" {
|
||||
return "", fmt.Errorf("tokenpony: no base URL configured for region %q", region)
|
||||
}
|
||||
@@ -92,7 +92,7 @@ func (a *TokenPonyModel) baseURLForRegion(region string) (string, error) {
|
||||
// full response. Forwards documented OpenAI-shaped parameters when the
|
||||
// caller supplies them; reasoning_content is surfaced separately so the
|
||||
// visible Answer is never polluted by chain-of-thought.
|
||||
func (a *TokenPonyModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
func (t *TokenPonyModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
if apiConfig == nil || apiConfig.ApiKey == nil || *apiConfig.ApiKey == "" {
|
||||
return nil, fmt.Errorf("api key is required")
|
||||
}
|
||||
@@ -105,11 +105,11 @@ func (a *TokenPonyModel) ChatWithMessages(modelName string, messages []Message,
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL, err := a.baseURLForRegion(region)
|
||||
baseURL, err := t.baseURLForRegion(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
url := fmt.Sprintf("%s/%s", baseURL, a.URLSuffix.Chat)
|
||||
url := fmt.Sprintf("%s/%s", baseURL, t.URLSuffix.Chat)
|
||||
|
||||
apiMessages := make([]map[string]interface{}, len(messages))
|
||||
for i, msg := range messages {
|
||||
@@ -155,7 +155,7 @@ func (a *TokenPonyModel) ChatWithMessages(modelName string, messages []Message,
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := a.httpClient.Do(req)
|
||||
resp, err := t.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -213,7 +213,7 @@ func (a *TokenPonyModel) ChatWithMessages(modelName string, messages []Message,
|
||||
// forwards each delta through the supplied sender. Reasoning chunks go
|
||||
// to the sender's second argument, content chunks to the first; the
|
||||
// stream is terminated by either `[DONE]` or a delta with finish_reason.
|
||||
func (a *TokenPonyModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
func (t *TokenPonyModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
if sender == nil {
|
||||
return fmt.Errorf("sender is required")
|
||||
}
|
||||
@@ -229,11 +229,11 @@ func (a *TokenPonyModel) ChatStreamlyWithSender(modelName string, messages []Mes
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL, err := a.baseURLForRegion(region)
|
||||
baseURL, err := t.baseURLForRegion(region)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
url := fmt.Sprintf("%s/%s", baseURL, a.URLSuffix.Chat)
|
||||
url := fmt.Sprintf("%s/%s", baseURL, t.URLSuffix.Chat)
|
||||
|
||||
apiMessages := make([]map[string]interface{}, len(messages))
|
||||
for i, msg := range messages {
|
||||
@@ -284,7 +284,7 @@ func (a *TokenPonyModel) ChatStreamlyWithSender(modelName string, messages []Mes
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := a.httpClient.Do(req)
|
||||
resp, err := t.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -373,7 +373,7 @@ func (a *TokenPonyModel) ChatStreamlyWithSender(modelName string, messages []Mes
|
||||
// ListModels returns the model ids visible to the API key by calling
|
||||
// /v1/models. Used by Add-Provider's connection check and by the UI's
|
||||
// model picker.
|
||||
func (a *TokenPonyModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
func (t *TokenPonyModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
if apiConfig == nil || apiConfig.ApiKey == nil || *apiConfig.ApiKey == "" {
|
||||
return nil, fmt.Errorf("api key is required")
|
||||
}
|
||||
@@ -383,11 +383,11 @@ func (a *TokenPonyModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL, err := a.baseURLForRegion(region)
|
||||
baseURL, err := t.baseURLForRegion(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
url := fmt.Sprintf("%s/%s", baseURL, a.URLSuffix.Models)
|
||||
url := fmt.Sprintf("%s/%s", baseURL, t.URLSuffix.Models)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), nonStreamCallTimeout)
|
||||
defer cancel()
|
||||
@@ -398,7 +398,7 @@ func (a *TokenPonyModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
}
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := a.httpClient.Do(req)
|
||||
resp, err := t.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -440,54 +440,54 @@ func (a *TokenPonyModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
// CheckConnection verifies the API key by calling ListModels. The /v1/models
|
||||
// endpoint is the documented lightweight way to validate credentials on
|
||||
// OpenAI-compatible gateways without burning chat-completion quota.
|
||||
func (a *TokenPonyModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := a.ListModels(apiConfig)
|
||||
func (t *TokenPonyModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := t.ListModels(apiConfig)
|
||||
return err
|
||||
}
|
||||
|
||||
// Embed is not implemented for TokenPony in this initial driver; the
|
||||
// factory entry only registers chat models. Mirrors how LongCat /
|
||||
// Astraflow landed chat-only.
|
||||
func (a *TokenPonyModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
func (t *TokenPonyModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", t.Name())
|
||||
}
|
||||
|
||||
func (a *TokenPonyModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
func (t *TokenPonyModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", t.Name())
|
||||
}
|
||||
|
||||
func (a *TokenPonyModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
func (t *TokenPonyModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", t.Name())
|
||||
}
|
||||
|
||||
func (a *TokenPonyModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
func (t *TokenPonyModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", t.Name())
|
||||
}
|
||||
|
||||
func (a *TokenPonyModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", a.Name())
|
||||
func (t *TokenPonyModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", t.Name())
|
||||
}
|
||||
|
||||
func (a *TokenPonyModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
func (t *TokenPonyModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", t.Name())
|
||||
}
|
||||
|
||||
func (a *TokenPonyModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", a.Name())
|
||||
func (t *TokenPonyModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", t.Name())
|
||||
}
|
||||
|
||||
func (a *TokenPonyModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
func (t *TokenPonyModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", t.Name())
|
||||
}
|
||||
|
||||
func (a *TokenPonyModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
func (t *TokenPonyModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", t.Name())
|
||||
}
|
||||
|
||||
func (a *TokenPonyModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
func (t *TokenPonyModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", t.Name())
|
||||
}
|
||||
|
||||
func (a *TokenPonyModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", a.Name())
|
||||
func (t *TokenPonyModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", t.Name())
|
||||
}
|
||||
|
||||
@@ -599,37 +599,37 @@ func (u *UpstageModel) Rerank(modelName *string, query string, documents []strin
|
||||
}
|
||||
|
||||
// TranscribeAudio transcribe audio
|
||||
func (z *UpstageModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (u *UpstageModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", u.Name())
|
||||
}
|
||||
|
||||
func (z *UpstageModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (u *UpstageModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", u.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech convert text to audio
|
||||
func (z *UpstageModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (u *UpstageModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", u.Name())
|
||||
}
|
||||
|
||||
func (z *UpstageModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (u *UpstageModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", u.Name())
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
func (z *UpstageModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (u *UpstageModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", u.Name())
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *UpstageModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (u *UpstageModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", u.Name())
|
||||
}
|
||||
|
||||
func (z *UpstageModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (u *UpstageModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", u.Name())
|
||||
}
|
||||
|
||||
func (z *UpstageModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (u *UpstageModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", u.Name())
|
||||
}
|
||||
|
||||
@@ -52,10 +52,10 @@ func NewVllmModel(baseURL map[string]string, urlSuffix URLSuffix) *VllmModel {
|
||||
}
|
||||
}
|
||||
|
||||
func (z *VllmModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
func (v *VllmModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return &VllmModel{
|
||||
BaseURL: baseURL,
|
||||
URLSuffix: z.URLSuffix,
|
||||
URLSuffix: v.URLSuffix,
|
||||
httpClient: &http.Client{
|
||||
Transport: &http.Transport{
|
||||
MaxIdleConns: 100,
|
||||
@@ -67,12 +67,12 @@ func (z *VllmModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
}
|
||||
}
|
||||
|
||||
func (z *VllmModel) Name() string {
|
||||
func (v *VllmModel) Name() string {
|
||||
return "vllm"
|
||||
}
|
||||
|
||||
// ChatWithMessages sends multiple messages with roles and returns response
|
||||
func (z *VllmModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
func (v *VllmModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
if len(messages) == 0 {
|
||||
return nil, fmt.Errorf("messages is empty")
|
||||
}
|
||||
@@ -82,12 +82,12 @@ func (z *VllmModel) ChatWithMessages(modelName string, messages []Message, apiCo
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", z.BaseURL[region], z.URLSuffix.Chat)
|
||||
url := fmt.Sprintf("%s/%s", v.BaseURL[region], v.URLSuffix.Chat)
|
||||
|
||||
// For qwen/glm models, use async chat endpoint
|
||||
modelType := strings.Split(modelName, "-")[0]
|
||||
if modelType == "qwen" || modelType == "glm" {
|
||||
url = fmt.Sprintf("%s/%s", z.BaseURL[region], z.URLSuffix.AsyncChat)
|
||||
url = fmt.Sprintf("%s/%s", v.BaseURL[region], v.URLSuffix.AsyncChat)
|
||||
}
|
||||
|
||||
// Convert messages to API format
|
||||
@@ -157,7 +157,7 @@ func (z *VllmModel) ChatWithMessages(modelName string, messages []Message, apiCo
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := v.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -218,7 +218,7 @@ func (z *VllmModel) ChatWithMessages(modelName string, messages []Message, apiCo
|
||||
}
|
||||
|
||||
// ChatStreamlyWithSender sends messages and streams response via sender function (best performance, no channel)
|
||||
func (z *VllmModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, modelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
func (v *VllmModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, modelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
if len(messages) == 0 {
|
||||
return fmt.Errorf("messages is empty")
|
||||
}
|
||||
@@ -228,10 +228,10 @@ func (z *VllmModel) ChatStreamlyWithSender(modelName string, messages []Message,
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", z.BaseURL[region], z.URLSuffix.Chat)
|
||||
url := fmt.Sprintf("%s/%s", v.BaseURL[region], v.URLSuffix.Chat)
|
||||
modelType := strings.Split(modelName, "-")[0]
|
||||
if modelType == "qwen" || modelType == "glm" {
|
||||
url = fmt.Sprintf("%s/%s", z.BaseURL[region], z.URLSuffix.AsyncChat)
|
||||
url = fmt.Sprintf("%s/%s", v.BaseURL[region], v.URLSuffix.AsyncChat)
|
||||
}
|
||||
|
||||
// Convert messages to API format (supporting multimodal content)
|
||||
@@ -302,7 +302,7 @@ func (z *VllmModel) ChatStreamlyWithSender(modelName string, messages []Message,
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := v.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -392,7 +392,7 @@ type vllmEmbeddingResponse struct {
|
||||
}
|
||||
|
||||
// Embed embeds a list of texts into embeddings
|
||||
func (z *VllmModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
func (v *VllmModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
if len(texts) == 0 {
|
||||
return []EmbeddingData{}, nil
|
||||
}
|
||||
@@ -406,15 +406,15 @@ func (z *VllmModel) Embed(modelName *string, texts []string, apiConfig *APIConfi
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL := z.BaseURL[region]
|
||||
baseURL := v.BaseURL[region]
|
||||
if baseURL == "" {
|
||||
baseURL = z.BaseURL["default"]
|
||||
baseURL = v.BaseURL["default"]
|
||||
}
|
||||
if baseURL == "" {
|
||||
return nil, fmt.Errorf("missing base URL: please configure the local access address for vLLM (e.g., http://127.0.0.1:8000/v1)")
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", strings.TrimSuffix(baseURL, "/"), z.URLSuffix.Embedding)
|
||||
url := fmt.Sprintf("%s/%s", strings.TrimSuffix(baseURL, "/"), v.URLSuffix.Embedding)
|
||||
|
||||
reqBody := map[string]interface{}{
|
||||
"model": *modelName,
|
||||
@@ -442,7 +442,7 @@ func (z *VllmModel) Embed(modelName *string, texts []string, apiConfig *APIConfi
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
}
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := v.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -473,22 +473,22 @@ func (z *VllmModel) Embed(modelName *string, texts []string, apiConfig *APIConfi
|
||||
return embeddings, nil
|
||||
}
|
||||
|
||||
func (z *VllmModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
func (v *VllmModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
var region = "default"
|
||||
|
||||
if apiConfig != nil && apiConfig.Region != nil && *apiConfig.Region != "" {
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL := z.BaseURL[region]
|
||||
baseURL := v.BaseURL[region]
|
||||
if baseURL == "" {
|
||||
baseURL = z.BaseURL["default"]
|
||||
baseURL = v.BaseURL["default"]
|
||||
}
|
||||
if baseURL == "" {
|
||||
return nil, fmt.Errorf("missing base URL: please configure the local access address for vLLM (e.g., http://127.0.0.1:8000/v1)")
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", baseURL, z.URLSuffix.Models)
|
||||
url := fmt.Sprintf("%s/%s", baseURL, v.URLSuffix.Models)
|
||||
|
||||
reqBody := map[string]interface{}{}
|
||||
|
||||
@@ -513,7 +513,7 @@ func (z *VllmModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
}
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := v.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -545,13 +545,13 @@ func (z *VllmModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
return models, nil
|
||||
}
|
||||
|
||||
func (z *VllmModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
func (v *VllmModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
return nil, fmt.Errorf("no such method")
|
||||
}
|
||||
|
||||
// CheckConnection verifies that the configured vLLM base URL is reachable
|
||||
func (z *VllmModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := z.ListModels(apiConfig)
|
||||
func (v *VllmModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := v.ListModels(apiConfig)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -584,7 +584,7 @@ type vllmRerankResponse struct {
|
||||
// Authorization header is sent only when APIConfig.ApiKey is non-empty,
|
||||
// matching the existing Embed/ListModels behaviour for this local
|
||||
// driver.
|
||||
func (z *VllmModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
func (v *VllmModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
if len(documents) == 0 {
|
||||
return &RerankResponse{}, nil
|
||||
}
|
||||
@@ -597,15 +597,15 @@ func (z *VllmModel) Rerank(modelName *string, query string, documents []string,
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL := z.BaseURL[region]
|
||||
baseURL := v.BaseURL[region]
|
||||
if baseURL == "" {
|
||||
baseURL = z.BaseURL["default"]
|
||||
baseURL = v.BaseURL["default"]
|
||||
}
|
||||
if baseURL == "" {
|
||||
return nil, fmt.Errorf("missing base URL: please configure the local access address for vLLM (e.g., http://127.0.0.1:8000/v1)")
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", strings.TrimSuffix(baseURL, "/"), z.URLSuffix.Rerank)
|
||||
url := fmt.Sprintf("%s/%s", strings.TrimSuffix(baseURL, "/"), v.URLSuffix.Rerank)
|
||||
|
||||
topN := len(documents)
|
||||
if rerankConfig != nil && rerankConfig.TopN > 0 && rerankConfig.TopN < topN {
|
||||
@@ -637,7 +637,7 @@ func (z *VllmModel) Rerank(modelName *string, query string, documents []string,
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
}
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := v.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -672,37 +672,37 @@ func (z *VllmModel) Rerank(modelName *string, query string, documents []string,
|
||||
}
|
||||
|
||||
// TranscribeAudio transcribe audio
|
||||
func (o *VllmModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", o.Name())
|
||||
func (v *VllmModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", v.Name())
|
||||
}
|
||||
|
||||
func (z *VllmModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (v *VllmModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", v.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech convert text to audio
|
||||
func (o *VllmModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", o.Name())
|
||||
func (v *VllmModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", v.Name())
|
||||
}
|
||||
|
||||
func (z *VllmModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (v *VllmModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", v.Name())
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
func (m *VllmModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (v *VllmModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", v.Name())
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *VllmModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (v *VllmModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", v.Name())
|
||||
}
|
||||
|
||||
func (z *VllmModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (v *VllmModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", v.Name())
|
||||
}
|
||||
|
||||
func (z *VllmModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (v *VllmModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", v.Name())
|
||||
}
|
||||
|
||||
@@ -52,16 +52,16 @@ func NewVolcEngine(baseURL map[string]string, urlSuffix URLSuffix) *VolcEngine {
|
||||
}
|
||||
}
|
||||
|
||||
func (z *VolcEngine) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
func (v *VolcEngine) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (z *VolcEngine) Name() string {
|
||||
func (v *VolcEngine) Name() string {
|
||||
return "volcengine"
|
||||
}
|
||||
|
||||
// ChatWithMessages sends multiple messages with roles and returns response
|
||||
func (z *VolcEngine) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
func (v *VolcEngine) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
if len(messages) == 0 {
|
||||
return nil, fmt.Errorf("messages is empty")
|
||||
}
|
||||
@@ -71,7 +71,7 @@ func (z *VolcEngine) ChatWithMessages(modelName string, messages []Message, apiC
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", z.BaseURL[region], z.URLSuffix.Chat)
|
||||
url := fmt.Sprintf("%s/%s", v.BaseURL[region], v.URLSuffix.Chat)
|
||||
|
||||
// Convert messages to API format
|
||||
apiMessages := make([]map[string]interface{}, len(messages))
|
||||
@@ -163,7 +163,7 @@ func (z *VolcEngine) ChatWithMessages(modelName string, messages []Message, apiC
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
}
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := v.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -224,7 +224,7 @@ func (z *VolcEngine) ChatWithMessages(modelName string, messages []Message, apiC
|
||||
}
|
||||
|
||||
// ChatStreamlyWithSender sends messages and streams response via sender function (best performance, no channel)
|
||||
func (z *VolcEngine) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, modelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
func (v *VolcEngine) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, modelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
if len(messages) == 0 {
|
||||
return fmt.Errorf("messages is empty")
|
||||
}
|
||||
@@ -235,7 +235,7 @@ func (z *VolcEngine) ChatStreamlyWithSender(modelName string, messages []Message
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/chat/completions", z.BaseURL[region])
|
||||
url := fmt.Sprintf("%s/chat/completions", v.BaseURL[region])
|
||||
|
||||
// Convert messages to API format
|
||||
apiMessages := make([]map[string]interface{}, len(messages))
|
||||
@@ -332,7 +332,7 @@ func (z *VolcEngine) ChatStreamlyWithSender(modelName string, messages []Message
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := v.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -439,7 +439,7 @@ type volcenginePromptTokensDetails struct {
|
||||
}
|
||||
|
||||
// Embed embeds a list of texts into embeddings
|
||||
func (z *VolcEngine) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
func (v *VolcEngine) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
if len(texts) == 0 {
|
||||
return []EmbeddingData{}, nil
|
||||
}
|
||||
@@ -449,7 +449,7 @@ func (z *VolcEngine) Embed(modelName *string, texts []string, apiConfig *APIConf
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", z.BaseURL[region], z.URLSuffix.Embedding)
|
||||
url := fmt.Sprintf("%s/%s", v.BaseURL[region], v.URLSuffix.Embedding)
|
||||
|
||||
var embeddings []EmbeddingData
|
||||
|
||||
@@ -491,7 +491,7 @@ func (z *VolcEngine) Embed(modelName *string, texts []string, apiConfig *APIConf
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := v.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return parsed, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -525,52 +525,52 @@ func (z *VolcEngine) Embed(modelName *string, texts []string, apiConfig *APIConf
|
||||
}
|
||||
|
||||
// Rerank calculates similarity scores between query and documents
|
||||
func (z *VolcEngine) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
return nil, fmt.Errorf("%s, Rerank not implemented", z.Name())
|
||||
func (v *VolcEngine) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
return nil, fmt.Errorf("%s, Rerank not implemented", v.Name())
|
||||
}
|
||||
|
||||
// TranscribeAudio transcribe audio
|
||||
func (o *VolcEngine) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", o.Name())
|
||||
func (v *VolcEngine) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", v.Name())
|
||||
}
|
||||
|
||||
func (z *VolcEngine) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (v *VolcEngine) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", v.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech convert text to audio
|
||||
func (o *VolcEngine) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", o.Name())
|
||||
func (v *VolcEngine) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", v.Name())
|
||||
}
|
||||
|
||||
func (z *VolcEngine) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (v *VolcEngine) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", v.Name())
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
func (m *VolcEngine) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (v *VolcEngine) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", v.Name())
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *VolcEngine) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (v *VolcEngine) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", v.Name())
|
||||
}
|
||||
|
||||
func (z *VolcEngine) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
func (v *VolcEngine) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
var region = "default"
|
||||
if apiConfig != nil && apiConfig.Region != nil && *apiConfig.Region != "" {
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL := z.BaseURL[region]
|
||||
baseURL := v.BaseURL[region]
|
||||
if baseURL == "" {
|
||||
baseURL = z.BaseURL["default"]
|
||||
baseURL = v.BaseURL["default"]
|
||||
}
|
||||
if baseURL == "" {
|
||||
return nil, fmt.Errorf("volcengine: no base URL configured for region %q", region)
|
||||
}
|
||||
modelsSuffix := strings.Trim(strings.TrimSpace(z.URLSuffix.Models), "/")
|
||||
modelsSuffix := strings.Trim(strings.TrimSpace(v.URLSuffix.Models), "/")
|
||||
if modelsSuffix == "" {
|
||||
return nil, fmt.Errorf("volcengine: models URL suffix is not configured")
|
||||
}
|
||||
@@ -589,7 +589,7 @@ func (z *VolcEngine) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
}
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := v.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -621,17 +621,17 @@ func (z *VolcEngine) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
return models, nil
|
||||
}
|
||||
|
||||
func (z *VolcEngine) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (v *VolcEngine) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", v.Name())
|
||||
}
|
||||
|
||||
func (z *VolcEngine) CheckConnection(apiConfig *APIConfig) error {
|
||||
func (v *VolcEngine) CheckConnection(apiConfig *APIConfig) error {
|
||||
var region = "default"
|
||||
if apiConfig != nil && apiConfig.Region != nil && *apiConfig.Region != "" {
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", z.BaseURL[region], z.URLSuffix.Files)
|
||||
url := fmt.Sprintf("%s/%s", v.BaseURL[region], v.URLSuffix.Files)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), nonStreamCallTimeout)
|
||||
defer cancel()
|
||||
@@ -644,7 +644,7 @@ func (z *VolcEngine) CheckConnection(apiConfig *APIConfig) error {
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := v.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -662,10 +662,10 @@ func (z *VolcEngine) CheckConnection(apiConfig *APIConfig) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (z *VolcEngine) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (v *VolcEngine) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", v.Name())
|
||||
}
|
||||
|
||||
func (z *VolcEngine) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (v *VolcEngine) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", v.Name())
|
||||
}
|
||||
|
||||
@@ -384,14 +384,14 @@ func (v *VoyageModel) OCRFile(modelName *string, content []byte, url *string, ap
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *VoyageModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (v *VoyageModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", v.Name())
|
||||
}
|
||||
|
||||
func (z *VoyageModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (v *VoyageModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", v.Name())
|
||||
}
|
||||
|
||||
func (z *VoyageModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (v *VoyageModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", v.Name())
|
||||
}
|
||||
|
||||
@@ -90,11 +90,11 @@ func NewXAIModel(baseURL map[string]string, urlSuffix URLSuffix) *XAIModel {
|
||||
}
|
||||
}
|
||||
|
||||
func (z *XAIModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return NewXAIModel(baseURL, z.URLSuffix)
|
||||
func (x *XAIModel) NewInstance(baseURL map[string]string) ModelDriver {
|
||||
return NewXAIModel(baseURL, x.URLSuffix)
|
||||
}
|
||||
|
||||
func (z *XAIModel) Name() string {
|
||||
func (x *XAIModel) Name() string {
|
||||
return "xai"
|
||||
}
|
||||
|
||||
@@ -102,8 +102,8 @@ func (z *XAIModel) Name() string {
|
||||
// error if no entry exists. This makes a misconfigured region fail
|
||||
// fast with a clear message, instead of silently producing a relative
|
||||
// URL that the HTTP transport then rejects.
|
||||
func (z *XAIModel) baseURLForRegion(region string) (string, error) {
|
||||
base, ok := z.BaseURL[region]
|
||||
func (x *XAIModel) baseURLForRegion(region string) (string, error) {
|
||||
base, ok := x.BaseURL[region]
|
||||
if !ok || base == "" {
|
||||
return "", fmt.Errorf("xai: no base URL configured for region %q", region)
|
||||
}
|
||||
@@ -111,7 +111,7 @@ func (z *XAIModel) baseURLForRegion(region string) (string, error) {
|
||||
}
|
||||
|
||||
// ChatWithMessages sends multiple messages with roles and returns the response
|
||||
func (z *XAIModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
func (x *XAIModel) ChatWithMessages(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig) (*ChatResponse, error) {
|
||||
if apiConfig == nil || apiConfig.ApiKey == nil || *apiConfig.ApiKey == "" {
|
||||
return nil, fmt.Errorf("api key is required")
|
||||
}
|
||||
@@ -125,11 +125,11 @@ func (z *XAIModel) ChatWithMessages(modelName string, messages []Message, apiCon
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL, err := z.baseURLForRegion(region)
|
||||
baseURL, err := x.baseURLForRegion(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
url := fmt.Sprintf("%s/%s", baseURL, z.URLSuffix.Chat)
|
||||
url := fmt.Sprintf("%s/%s", baseURL, x.URLSuffix.Chat)
|
||||
|
||||
// Convert messages to the format expected by the API
|
||||
apiMessages := make([]map[string]interface{}, len(messages))
|
||||
@@ -185,7 +185,7 @@ func (z *XAIModel) ChatWithMessages(modelName string, messages []Message, apiCon
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := x.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -246,7 +246,7 @@ func (z *XAIModel) ChatWithMessages(modelName string, messages []Message, apiCon
|
||||
|
||||
// ChatStreamlyWithSender sends messages and streams the response via the
|
||||
// sender function. Used for streaming chat responses with no extra channel.
|
||||
func (z *XAIModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
func (x *XAIModel) ChatStreamlyWithSender(modelName string, messages []Message, apiConfig *APIConfig, chatModelConfig *ChatConfig, sender func(*string, *string) error) error {
|
||||
if len(messages) == 0 {
|
||||
return fmt.Errorf("messages is empty")
|
||||
}
|
||||
@@ -260,11 +260,11 @@ func (z *XAIModel) ChatStreamlyWithSender(modelName string, messages []Message,
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL, err := z.baseURLForRegion(region)
|
||||
baseURL, err := x.baseURLForRegion(region)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
url := fmt.Sprintf("%s/%s", baseURL, z.URLSuffix.Chat)
|
||||
url := fmt.Sprintf("%s/%s", baseURL, x.URLSuffix.Chat)
|
||||
|
||||
// Convert messages to API format (supports multimodal content)
|
||||
apiMessages := make([]map[string]interface{}, len(messages))
|
||||
@@ -325,7 +325,7 @@ func (z *XAIModel) ChatStreamlyWithSender(modelName string, messages []Message,
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := x.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -424,12 +424,12 @@ func (z *XAIModel) ChatStreamlyWithSender(modelName string, messages []Message,
|
||||
|
||||
// Embed embeds a list of texts into embeddings. xAI does not expose a
|
||||
// public embedding API yet, so this is left unimplemented.
|
||||
func (z *XAIModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
func (x *XAIModel) Embed(modelName *string, texts []string, apiConfig *APIConfig, embeddingConfig *EmbeddingConfig) ([]EmbeddingData, error) {
|
||||
return nil, fmt.Errorf("not implemented")
|
||||
}
|
||||
|
||||
// ListModels returns the list of model ids visible to the API key.
|
||||
func (z *XAIModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
func (x *XAIModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
if apiConfig == nil || apiConfig.ApiKey == nil || *apiConfig.ApiKey == "" {
|
||||
return nil, fmt.Errorf("api key is required")
|
||||
}
|
||||
@@ -439,11 +439,11 @@ func (z *XAIModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
baseURL, err := z.baseURLForRegion(region)
|
||||
baseURL, err := x.baseURLForRegion(region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
modelsSuffix := strings.Trim(strings.TrimSpace(z.URLSuffix.Models), "/")
|
||||
modelsSuffix := strings.Trim(strings.TrimSpace(x.URLSuffix.Models), "/")
|
||||
if modelsSuffix == "" {
|
||||
return nil, fmt.Errorf("xai: models URL suffix is not configured")
|
||||
}
|
||||
@@ -460,7 +460,7 @@ func (z *XAIModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := z.httpClient.Do(req)
|
||||
resp, err := x.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -503,13 +503,13 @@ func (z *XAIModel) ListModels(apiConfig *APIConfig) ([]string, error) {
|
||||
}
|
||||
|
||||
// Balance is not exposed by the xAI API, so this returns "no such method".
|
||||
func (z *XAIModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
func (x *XAIModel) Balance(apiConfig *APIConfig) (map[string]interface{}, error) {
|
||||
return nil, fmt.Errorf("no such method")
|
||||
}
|
||||
|
||||
// CheckConnection runs a lightweight ListModels call to verify the API key.
|
||||
func (z *XAIModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := z.ListModels(apiConfig)
|
||||
func (x *XAIModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
_, err := x.ListModels(apiConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -518,12 +518,12 @@ func (z *XAIModel) CheckConnection(apiConfig *APIConfig) error {
|
||||
|
||||
// Rerank calculates similarity scores between query and documents. xAI does not
|
||||
// expose a rerank API, so this is left unimplemented.
|
||||
func (z *XAIModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
return nil, fmt.Errorf("%s, Rerank not implemented", z.Name())
|
||||
func (x *XAIModel) Rerank(modelName *string, query string, documents []string, apiConfig *APIConfig, rerankConfig *RerankConfig) (*RerankResponse, error) {
|
||||
return nil, fmt.Errorf("%s, Rerank not implemented", x.Name())
|
||||
}
|
||||
|
||||
// TranscribeAudio transcribe audio
|
||||
func (o *XAIModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
func (x *XAIModel) TranscribeAudio(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig) (*ASRResponse, error) {
|
||||
if file == nil || *file == "" {
|
||||
return nil, fmt.Errorf("file is missing")
|
||||
}
|
||||
@@ -533,7 +533,7 @@ func (o *XAIModel) TranscribeAudio(modelName *string, file *string, apiConfig *A
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", o.BaseURL[region], o.URLSuffix.ASR)
|
||||
url := fmt.Sprintf("%s/%s", x.BaseURL[region], x.URLSuffix.ASR)
|
||||
|
||||
// multipart body
|
||||
var body bytes.Buffer
|
||||
@@ -620,7 +620,7 @@ func (o *XAIModel) TranscribeAudio(modelName *string, file *string, apiConfig *A
|
||||
req.Header.Set("Content-Type", writer.FormDataContentType())
|
||||
|
||||
// send request
|
||||
resp, err := o.httpClient.Do(req)
|
||||
resp, err := x.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -647,12 +647,12 @@ func (o *XAIModel) TranscribeAudio(modelName *string, file *string, apiConfig *A
|
||||
return &ASRResponse{Text: result.Text}, nil
|
||||
}
|
||||
|
||||
func (z *XAIModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (x *XAIModel) TranscribeAudioWithSender(modelName *string, file *string, apiConfig *APIConfig, asrConfig *ASRConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", x.Name())
|
||||
}
|
||||
|
||||
// AudioSpeech convert text to audio
|
||||
func (o *XAIModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
func (x *XAIModel) AudioSpeech(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig) (*TTSResponse, error) {
|
||||
if apiConfig == nil || apiConfig.ApiKey == nil || *apiConfig.ApiKey == "" {
|
||||
return nil, fmt.Errorf("xai API key is missing")
|
||||
}
|
||||
@@ -666,7 +666,7 @@ func (o *XAIModel) AudioSpeech(modelName *string, audioContent *string, apiConfi
|
||||
region = *apiConfig.Region
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/%s", o.BaseURL[region], o.URLSuffix.TTS)
|
||||
url := fmt.Sprintf("%s/%s", x.BaseURL[region], x.URLSuffix.TTS)
|
||||
|
||||
reqBody := map[string]interface{}{
|
||||
"text": *audioContent,
|
||||
@@ -697,7 +697,7 @@ func (o *XAIModel) AudioSpeech(modelName *string, audioContent *string, apiConfi
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", *apiConfig.ApiKey))
|
||||
|
||||
resp, err := o.httpClient.Do(req)
|
||||
resp, err := x.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
@@ -715,24 +715,24 @@ func (o *XAIModel) AudioSpeech(modelName *string, audioContent *string, apiConfi
|
||||
return &TTSResponse{Audio: body}, nil
|
||||
}
|
||||
|
||||
func (z *XAIModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", z.Name())
|
||||
func (x *XAIModel) AudioSpeechWithSender(modelName *string, audioContent *string, apiConfig *APIConfig, ttsConfig *TTSConfig, sender func(*string, *string) error) error {
|
||||
return fmt.Errorf("%s, no such method", x.Name())
|
||||
}
|
||||
|
||||
// OCRFile OCR file
|
||||
func (m *XAIModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", m.Name())
|
||||
func (x *XAIModel) OCRFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, ocrConfig *OCRConfig) (*OCRFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", x.Name())
|
||||
}
|
||||
|
||||
// ParseFile parse file
|
||||
func (z *XAIModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (x *XAIModel) ParseFile(modelName *string, content []byte, url *string, apiConfig *APIConfig, parseFileConfig *ParseFileConfig) (*ParseFileResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", x.Name())
|
||||
}
|
||||
|
||||
func (z *XAIModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (x *XAIModel) ListTasks(apiConfig *APIConfig) ([]ListTaskStatus, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", x.Name())
|
||||
}
|
||||
|
||||
func (z *XAIModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", z.Name())
|
||||
func (x *XAIModel) ShowTask(taskID string, apiConfig *APIConfig) (*TaskResponse, error) {
|
||||
return nil, fmt.Errorf("%s, no such method", x.Name())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user