Skip to content

Commit 175227b

Browse files
committed
feat(doc): enhance provider configurations
Updated baseUrl to use full URLs with protocol for OpenAI and Anthropic. Enhanced provider configuration setup by including Gemini, Moonshot, and Deepseek services with appropriate comments and logging for initialization.
1 parent ce64e19 commit 175227b

File tree

1 file changed

+47
-15
lines changed

1 file changed

+47
-15
lines changed

README.md

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ implementation("com.tddworks:openai-gateway-jvm:0.2.1")
7474
**Then, configure the OpenAIGateway with your API keys and settings:**
7575
- Default values are provided for the baseUrl, but you can override them with your own values.
7676
- OpenAI
77-
- default baseUrl is `api.openai.com`
77+
- default baseUrl is `https://api.openai.com`
7878
- Anthropic
79-
- default baseUrl is `api.anthropic.com`
79+
- default baseUrl is `https://api.anthropic.com`
8080
- default anthropicVersion is `2023-06-01`
8181
- Ollama
8282
- default baseUrl is `localhost`
@@ -95,22 +95,54 @@ import com.tddworks.openai.api.chat.api.Model
9595
import com.tddworks.openai.gateway.api.OpenAIGateway
9696
import com.tddworks.openai.gateway.di.initOpenAIGateway
9797

98-
val openAIGateway = initOpenAIGateway(
99-
OpenAIConfig(
100-
baseUrl = { "YOUR_OPENAI_BASE_URL" },
101-
apiKey = { "YOUR_OPENAI_API_KEY" }
98+
99+
initOpenAIGateway(
100+
DefaultOpenAIProviderConfig(
101+
baseUrl = { "YOUR_OPENAI_BASE_URL" }, // Replace with the base URL for the OpenAI API
102+
apiKey = { "YOUR_OPENAI_API_KEY" } // Replace with your OpenAI API key
103+
),
104+
AnthropicOpenAIProviderConfig(
105+
baseUrl = { "YOUR_ANTHROPIC_BASE_URL" }, // Replace with the base URL for the Anthropic service
106+
apiKey = { "YOUR_ANTHROPIC_API_KEY" }, // Replace with your Anthropic API key
107+
anthropicVersion = { "ANTHROPIC_API_VERSION" } // Replace with the version of Anthropic API you want to use
102108
),
103-
AnthropicConfig(
104-
baseUrl = { "YOUR_ANTHROPIC_BASE_URL" },
105-
apiKey = { "YOUR_ANTHROPIC_API_KEY" },
106-
anthropicVersion = { "YOUR_ANTHROPIC_VERSION" }
109+
OllamaOpenAIProviderConfig(
110+
protocol = { "PROTOCOL" }, // Replace with the protocol (e.g., 'http' or 'https')
111+
baseUrl = { "YOUR_OLLAMA_BASE_URL" }, // Replace with the base URL for the Ollama service
112+
port = { "PORT_NUMBER" } // Replace with the port number if required
107113
),
108-
OllamaConfig(
109-
baseUrl = { "YOUR_OLLAMA_BASE_URL" },
110-
protocol = { "YOUR_OLLAMA_PROTOCOL" },
111-
port = { "YOUR_OLLAMA_PORT" }
114+
GeminiOpenAIProviderConfig(
115+
baseUrl = { "YOUR_GEMINI_BASE_URL" }, // Replace with the base URL for the Gemini service
116+
apiKey = { "YOUR_GEMINI_API_KEY" } // Replace with your Gemini API key
112117
)
113-
)
118+
).apply {
119+
addProvider(
120+
DefaultOpenAIProvider(
121+
config = DefaultOpenAIProviderConfig(
122+
baseUrl = { "YOUR_MOONSHOT_BASE_URL" }, // Replace with the base URL for the Moonshot service
123+
apiKey = { "YOUR_MOONSHOT_API_KEY" } // Replace with your Moonshot API key
124+
),
125+
models = moonshotmodels.map { // Replace with the models you wish to use with the Moonshot service
126+
OpenAIModel(it.name) // Define the models you wish to use with the Moonshot service
127+
}
128+
)
129+
)
130+
131+
addProvider(
132+
DefaultOpenAIProvider(
133+
config = DefaultOpenAIProviderConfig(
134+
baseUrl = { "YOUR_DEEPSEEK_BASE_URL" }, // Replace with the base URL for the Deepseek service
135+
apiKey = { "YOUR_DEEPSEEK_API_KEY" } // Replace with your Deepseek API key
136+
),
137+
models = deepseekModels.map { // Replace with the models you wish to use with the Deepseek service
138+
OpenAIModel(it.name) // Define the models you wish to use with the Deepseek service
139+
}
140+
)
141+
)
142+
}.also {
143+
Logger.d("OpenAI Gateway initialized") // Log the initialization of the OpenAI Gateway
144+
}
145+
114146

115147
// stream completions
116148
openAIGateway.streamChatCompletions(

0 commit comments

Comments
 (0)