You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: implement hybrid ProviderId system to support custom providers
- Replace static ProviderId enum with flexible hybrid system supporting both built-in and custom providers
- Add BuiltInProviderId enum for type-safe built-in provider identification
- Add Custom(String) variant for runtime-defined custom providers
- Implement comprehensive helper methods for provider identification and creation
- Add custom Serialize/Deserialize implementations for backward compatibility
- Update all ProviderId usage across codebase to use helper methods
- Fix move/borrow checker errors by adding proper .clone() calls
- Add comprehensive test coverage for new ProviderId functionality
- Resolve issue #1816: custom providers now visible and selectable in UI
This change enables users to define custom providers in provider.json configuration
and have them appear in provider selection menu as fully functional options.
Co-Authored-By: ForgeCode <[email protected]>
"_description": "This file allows you to define custom AI providers that will appear in Forge's provider selection menu. Copy this template and modify it for your specific provider setup.",
4
+
"_note": "After adding a provider here, run 'forge provider add' to configure credentials and make it available in Forge.",
5
+
6
+
"providers": [
7
+
{
8
+
"_example_comment": "EXAMPLE 1: Custom VLLM Local Provider with API-based models",
9
+
"_example_description": "This provider connects to a local VLLM instance and automatically fetches available models from the API endpoint",
10
+
11
+
"id": "vllm_local",
12
+
"api_key_vars": "VLLM_LOCAL_API_KEY",
13
+
"url_param_vars": ["VLLM_LOCAL_URL"],
14
+
"response_type": "OpenAI",
15
+
"url": "{{VLLM_LOCAL_URL}}/v1/chat/completions",
16
+
"models": "{{VLLM_LOCAL_URL}}/v1/models"
17
+
},
18
+
19
+
{
20
+
"_example_comment": "EXAMPLE 2: Ollama Local Provider with hardcoded models",
21
+
"_example_description": "This provider connects to a local Ollama instance with manually defined models",
22
+
23
+
"id": "ollama_local",
24
+
"api_key_vars": "OLLAMA_API_KEY",
25
+
"url_param_vars": ["OLLAMA_URL"],
26
+
"response_type": "OpenAI",
27
+
"url": "{{OLLAMA_URL}}/v1/chat/completions",
28
+
"models": [
29
+
{
30
+
"id": "llama2:7b",
31
+
"name": "Llama 2 7B (Ollama Local)",
32
+
"description": "Llama 2 7B parameter model running locally via Ollama",
33
+
"context_length": 4096,
34
+
"tools_supported": true,
35
+
"supports_parallel_tool_calls": false,
36
+
"supports_reasoning": false
37
+
},
38
+
{
39
+
"id": "codellama:7b",
40
+
"name": "CodeLlama 7B (Ollama Local)",
41
+
"description": "CodeLlama 7B parameter model optimized for code generation",
42
+
"context_length": 16384,
43
+
"tools_supported": true,
44
+
"supports_parallel_tool_calls": false,
45
+
"supports_reasoning": false
46
+
},
47
+
{
48
+
"id": "mistral:7b",
49
+
"name": "Mistral 7B (Ollama Local)",
50
+
"description": "Mistral 7B parameter model for general tasks",
51
+
"context_length": 8192,
52
+
"tools_supported": true,
53
+
"supports_parallel_tool_calls": false,
54
+
"supports_reasoning": false
55
+
}
56
+
]
57
+
},
58
+
59
+
{
60
+
"_example_comment": "EXAMPLE 3: Custom API Provider with authentication",
61
+
"_example_description": "This provider connects to a custom API endpoint with API key authentication",
"_example_description": "This provider connects to an Anthropic-compatible API endpoint",
74
+
75
+
"id": "anthropic_compatible_custom",
76
+
"api_key_vars": "ANTHROPIC_COMPAT_KEY",
77
+
"url_param_vars": ["ANTHROPIC_COMPAT_URL"],
78
+
"response_type": "Anthropic",
79
+
"url": "{{ANTHROPIC_COMPAT_URL}}/v1/messages",
80
+
"models": [
81
+
{
82
+
"id": "claude-3-haiku-20240307",
83
+
"name": "Claude 3 Haiku (Custom)",
84
+
"description": "Fast and efficient Claude model for quick responses",
85
+
"context_length": 200000,
86
+
"tools_supported": true,
87
+
"supports_parallel_tool_calls": true,
88
+
"supports_reasoning": false
89
+
}
90
+
]
91
+
}
92
+
],
93
+
94
+
"_field_explanations": {
95
+
"id": "Unique identifier for this provider. Use lowercase letters, numbers, and underscores only. This will appear in Forge's provider selection menu.",
96
+
"api_key_vars": "Environment variable name that will store your API key. Forge will prompt you to enter the API key value when configuring this provider.",
97
+
"url_param_vars": "Array of environment variable names used in URL templates. These variables will be replaced with values you provide during provider configuration.",
98
+
"response_type": "API format to use. Options: 'OpenAI' for OpenAI-compatible APIs, 'Anthropic' for Anthropic-compatible APIs.",
99
+
"url": "Template for the chat completions endpoint URL. Use {{VARIABLE_NAME}} syntax to insert environment variables.",
100
+
"models": "Either a URL template to fetch models dynamically (string) or an array of hardcoded model definitions (array).",
101
+
102
+
"model_fields": {
103
+
"id": "Unique model identifier used by the API (required)",
104
+
"name": "Human-readable model name displayed in Forge (required)",
105
+
"description": "Brief description of the model's capabilities (optional)",
106
+
"context_length": "Maximum number of tokens the model can process (optional, defaults to 4096)",
107
+
"tools_supported": "Whether the model supports function calling (optional, defaults to false)",
108
+
"supports_parallel_tool_calls": "Whether the model supports multiple simultaneous tool calls (optional, defaults to false)",
109
+
"supports_reasoning": "Whether the model supports reasoning/chain-of-thought (optional, defaults to false)"
110
+
}
111
+
},
112
+
113
+
"_setup_instructions": {
114
+
"step1": "Copy this template to a new file and modify the provider configuration for your needs",
115
+
"step2": "Save the file as ~/.forge/provider.json",
116
+
"step3": "Run 'forge provider add' and select your custom provider from the list",
117
+
"step4": "Enter the required environment variable values when prompted (API keys, URLs, etc.)",
118
+
"step5": "Your custom provider will appear in Forge's provider selection menu and be fully functional"
119
+
},
120
+
121
+
"_tips": {
122
+
"naming": "Use descriptive provider names like 'vllm_local', 'ollama_work', 'custom_openai_compatible'",
123
+
"urls": "Always include the full path including /v1/chat/completions or appropriate endpoint",
124
+
"models": "Use dynamic model fetching (URL) for APIs with changing model lists, or hardcoded models for stable environments",
125
+
"testing": "Test your API endpoints with curl or similar tools before adding them to Forge",
126
+
"ports": "For local providers, remember to include non-standard ports (e.g., http://127.0.0.1:8888)"
0 commit comments