chore: formatting and minor fixes
This commit is contained in:
parent
b6d1ae637a
commit
399a3c8ef3
4 changed files with 19 additions and 19 deletions
|
|
@ -20,9 +20,9 @@ type Model struct {
|
||||||
Prompt string `json:"prompt"`
|
Prompt string `json:"prompt"`
|
||||||
Completion string `json:"completion"`
|
Completion string `json:"completion"`
|
||||||
} `json:"pricing"`
|
} `json:"pricing"`
|
||||||
Created int64 `json:"created"`
|
Created int64 `json:"created"`
|
||||||
Score float64
|
Score float64
|
||||||
LastError string
|
LastError string
|
||||||
IsReachable bool
|
IsReachable bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,7 +70,7 @@ func main() {
|
||||||
}
|
}
|
||||||
m := &freeModels[i]
|
m := &freeModels[i]
|
||||||
fmt.Printf("[%d/%d] Testing %s... ", i+1, len(freeModels), m.ID)
|
fmt.Printf("[%d/%d] Testing %s... ", i+1, len(freeModels), m.ID)
|
||||||
|
|
||||||
err := testModel(apiKey, m.ID)
|
err := testModel(apiKey, m.ID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
m.IsReachable = true
|
m.IsReachable = true
|
||||||
|
|
@ -113,7 +113,7 @@ func main() {
|
||||||
func fetchModels(apiKey string) ([]Model, error) {
|
func fetchModels(apiKey string) ([]Model, error) {
|
||||||
req, _ := http.NewRequest("GET", "https://openrouter.ai/api/v1/models", nil)
|
req, _ := http.NewRequest("GET", "https://openrouter.ai/api/v1/models", nil)
|
||||||
req.Header.Set("Authorization", "Bearer "+apiKey)
|
req.Header.Set("Authorization", "Bearer "+apiKey)
|
||||||
|
|
||||||
resp, err := http.DefaultClient.Do(req)
|
resp, err := http.DefaultClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -138,11 +138,11 @@ func testModel(apiKey, modelID string) error {
|
||||||
"max_tokens": 10,
|
"max_tokens": 10,
|
||||||
}
|
}
|
||||||
body, _ := json.Marshal(payload)
|
body, _ := json.Marshal(payload)
|
||||||
|
|
||||||
req, _ := http.NewRequest("POST", "https://openrouter.ai/api/v1/chat/completions", bytes.NewReader(body))
|
req, _ := http.NewRequest("POST", "https://openrouter.ai/api/v1/chat/completions", bytes.NewReader(body))
|
||||||
req.Header.Set("Authorization", "Bearer "+apiKey)
|
req.Header.Set("Authorization", "Bearer "+apiKey)
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
|
||||||
client := &http.Client{Timeout: 10 * time.Second}
|
client := &http.Client{Timeout: 10 * time.Second}
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -154,6 +154,6 @@ func testModel(apiKey, modelID string) error {
|
||||||
respBody, _ := io.ReadAll(resp.Body)
|
respBody, _ := io.ReadAll(resp.Body)
|
||||||
return fmt.Errorf("HTTP %d: %s", resp.StatusCode, string(respBody))
|
return fmt.Errorf("HTTP %d: %s", resp.StatusCode, string(respBody))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -153,15 +153,15 @@ func NewAgentLoop(
|
||||||
|
|
||||||
eventBus := NewEventBus()
|
eventBus := NewEventBus()
|
||||||
al := &AgentLoop{
|
al := &AgentLoop{
|
||||||
bus: msgBus,
|
bus: msgBus,
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
configPath: configPath,
|
configPath: configPath,
|
||||||
registry: registry,
|
registry: registry,
|
||||||
state: stateManager,
|
state: stateManager,
|
||||||
eventBus: eventBus,
|
eventBus: eventBus,
|
||||||
fallback: fallbackChain,
|
fallback: fallbackChain,
|
||||||
cmdRegistry: commands.NewRegistry(commands.BuiltinDefinitions()),
|
cmdRegistry: commands.NewRegistry(commands.BuiltinDefinitions()),
|
||||||
steering: newSteeringQueue(parseSteeringMode(cfg.Agents.Defaults.SteeringMode)),
|
steering: newSteeringQueue(parseSteeringMode(cfg.Agents.Defaults.SteeringMode)),
|
||||||
}
|
}
|
||||||
|
|
||||||
al.agentCacheTTL = 24 * time.Hour
|
al.agentCacheTTL = 24 * time.Hour
|
||||||
|
|
|
||||||
|
|
@ -240,7 +240,7 @@ func (t *FreeRideTool) handleAuto(ctx context.Context, limit int) *ToolResult {
|
||||||
|
|
||||||
msg := fmt.Sprintf("Success! Added %d free models as fallbacks: %s.\n", len(addedModels), strings.Join(addedModels, ", "))
|
msg := fmt.Sprintf("Success! Added %d free models as fallbacks: %s.\n", len(addedModels), strings.Join(addedModels, ", "))
|
||||||
msg += "Re-loading configuration to apply changes..."
|
msg += "Re-loading configuration to apply changes..."
|
||||||
|
|
||||||
if t.reloadFunc != nil {
|
if t.reloadFunc != nil {
|
||||||
if err := t.reloadFunc(); err != nil {
|
if err := t.reloadFunc(); err != nil {
|
||||||
return ErrorResult(fmt.Sprintf("%s\nFailed to reload: %v", msg, err))
|
return ErrorResult(fmt.Sprintf("%s\nFailed to reload: %v", msg, err))
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ func TestFreeRideTool_Auto(t *testing.T) {
|
||||||
ModelList: []*config.ModelConfig{},
|
ModelList: []*config.ModelConfig{},
|
||||||
}
|
}
|
||||||
initialCfg.Agents.Defaults.ModelName = "existing-model"
|
initialCfg.Agents.Defaults.ModelName = "existing-model"
|
||||||
|
|
||||||
if err := config.SaveConfig(configPath, initialCfg); err != nil {
|
if err := config.SaveConfig(configPath, initialCfg); err != nil {
|
||||||
t.Fatalf("failed to save initial config: %v", err)
|
t.Fatalf("failed to save initial config: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue