Feat: openrouter fetch/update free model list
This commit is contained in:
		| @@ -95,3 +95,52 @@ func (b *Bot) ToPlayer() *models.Player { | ||||
| 		IsBot:    true, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| type ORModel struct { | ||||
| 	ID            string `json:"id"` | ||||
| 	CanonicalSlug string `json:"canonical_slug"` | ||||
| 	HuggingFaceID string `json:"hugging_face_id"` | ||||
| 	Name          string `json:"name"` | ||||
| 	Created       int    `json:"created"` | ||||
| 	Description   string `json:"description"` | ||||
| 	ContextLength int    `json:"context_length"` | ||||
| 	Architecture  struct { | ||||
| 		Modality         string   `json:"modality"` | ||||
| 		InputModalities  []string `json:"input_modalities"` | ||||
| 		OutputModalities []string `json:"output_modalities"` | ||||
| 		Tokenizer        string   `json:"tokenizer"` | ||||
| 		InstructType     any      `json:"instruct_type"` | ||||
| 	} `json:"architecture"` | ||||
| 	Pricing struct { | ||||
| 		Prompt            string `json:"prompt"` | ||||
| 		Completion        string `json:"completion"` | ||||
| 		Request           string `json:"request"` | ||||
| 		Image             string `json:"image"` | ||||
| 		Audio             string `json:"audio"` | ||||
| 		WebSearch         string `json:"web_search"` | ||||
| 		InternalReasoning string `json:"internal_reasoning"` | ||||
| 	} `json:"pricing,omitempty"` | ||||
| 	TopProvider struct { | ||||
| 		ContextLength       int  `json:"context_length"` | ||||
| 		MaxCompletionTokens int  `json:"max_completion_tokens"` | ||||
| 		IsModerated         bool `json:"is_moderated"` | ||||
| 	} `json:"top_provider"` | ||||
| 	PerRequestLimits    any      `json:"per_request_limits"` | ||||
| 	SupportedParameters []string `json:"supported_parameters"` | ||||
| } | ||||
|  | ||||
| // https://openrouter.ai/api/v1/models | ||||
| type ORModels struct { | ||||
| 	Data []ORModel `json:"data"` | ||||
| } | ||||
|  | ||||
| func (orm *ORModels) ListFree() []string { | ||||
| 	resp := []string{} | ||||
| 	for _, model := range orm.Data { | ||||
| 		if model.Pricing.Prompt == "0" && model.Pricing.Request == "0" && | ||||
| 			model.Pricing.Completion == "0" { | ||||
| 			resp = append(resp, model.ID) | ||||
| 		} | ||||
| 	} | ||||
| 	return resp | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder