mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-10-14 05:30:55 +00:00
Fix OpenAI-compatible endpoint support for chat
Two issues fixed: 1. Custom base URL wasn't being passed to the OpenAI client in createProviderForModel() - requests went to api.openai.com instead of the configured endpoint (e.g., LM Studio, llama.cpp) 2. Tool schemas were missing the "properties" field when tools had no parameters. OpenAI API requires "properties" to always be present as an object, even if empty. Fixes #1154
This commit is contained in:
parent
1be9e6a024
commit
900e05025a
2 changed files with 18 additions and 19 deletions
|
|
@ -728,7 +728,7 @@ func (s *Service) createProviderForModel(modelStr string) (providers.StreamingPr
|
|||
if s.cfg.OpenAIAPIKey == "" {
|
||||
return nil, fmt.Errorf("OpenAI API key not configured")
|
||||
}
|
||||
return providers.NewOpenAIClient(s.cfg.OpenAIAPIKey, modelName, "", timeout), nil
|
||||
return providers.NewOpenAIClient(s.cfg.OpenAIAPIKey, modelName, s.cfg.OpenAIBaseURL, timeout), nil
|
||||
case "deepseek":
|
||||
if s.cfg.DeepSeekAPIKey == "" {
|
||||
return nil, fmt.Errorf("DeepSeek API key not configured")
|
||||
|
|
|
|||
|
|
@ -14,26 +14,25 @@ func ConvertMCPToolsToProvider(mcpTools []tools.Tool) []providers.Tool {
|
|||
inputSchema := make(map[string]interface{})
|
||||
inputSchema["type"] = "object"
|
||||
|
||||
// Convert properties
|
||||
if len(t.InputSchema.Properties) > 0 {
|
||||
props := make(map[string]interface{})
|
||||
for name, prop := range t.InputSchema.Properties {
|
||||
propDef := map[string]interface{}{
|
||||
"type": prop.Type,
|
||||
}
|
||||
if prop.Description != "" {
|
||||
propDef["description"] = prop.Description
|
||||
}
|
||||
if len(prop.Enum) > 0 {
|
||||
propDef["enum"] = prop.Enum
|
||||
}
|
||||
if prop.Default != nil {
|
||||
propDef["default"] = prop.Default
|
||||
}
|
||||
props[name] = propDef
|
||||
// Convert properties - always include "properties" even if empty
|
||||
// OpenAI API requires "properties" to be present as an object
|
||||
props := make(map[string]interface{})
|
||||
for name, prop := range t.InputSchema.Properties {
|
||||
propDef := map[string]interface{}{
|
||||
"type": prop.Type,
|
||||
}
|
||||
inputSchema["properties"] = props
|
||||
if prop.Description != "" {
|
||||
propDef["description"] = prop.Description
|
||||
}
|
||||
if len(prop.Enum) > 0 {
|
||||
propDef["enum"] = prop.Enum
|
||||
}
|
||||
if prop.Default != nil {
|
||||
propDef["default"] = prop.Default
|
||||
}
|
||||
props[name] = propDef
|
||||
}
|
||||
inputSchema["properties"] = props
|
||||
|
||||
// Add required fields
|
||||
if len(t.InputSchema.Required) > 0 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue