Class CodeMieProvider
- All Implemented Interfaces:
Genai
Genai implementation that integrates with EPAM CodeMie.
This provider authenticates against a CodeMie OpenID Connect (OIDC) token endpoint to obtain an OAuth 2.0 access token and then configures an OpenAI-compatible backend (CodeMie Code Assistant REST API).
Authentication modes
- Password grant is used when
GENAI_USERNAMEcontains"@"(typical e-mail login). - Client credentials is used otherwise (service-to-service).
Provider delegation
After retrieving a token, this provider sets the following configuration keys before delegating to a downstream provider:
OPENAI_BASE_URLtoBASE_URLOPENAI_API_KEYto the retrieved access token
Delegation is selected based on the configured chatModel prefix:
gpt-*(or blank/unspecified) models delegate toOpenAIProvidergemini-*models delegate toGeminiProviderclaude-*models delegate toClaudeProvider
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault OpenID Connect token endpoint for CodeMie.static final StringConfiguration key used to override the default token endpoint.static final StringBase URL for the CodeMie Code Assistant API.static final StringConfiguration/environment key used by OpenAI-compatible clients to provide the API key.Fields inherited from class org.machanism.machai.ai.provider.GenaiAdapter
providerFields inherited from interface org.machanism.machai.ai.provider.Genai
LINE_SEPARATOR, LOG_INPUTS_PROP_NAME, PARAGRAPH_SEPARATOR, PASSWORD_PROP_NAME, SERVERID_PROP_NAME, USERNAME_PROP_NAME -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.machanism.machai.ai.provider.GenaiAdapter
addTool, clear, embedding, inputsLog, instructions, perform, prompt, setProvider, setWorkingDir, usageMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.machanism.machai.ai.provider.Genai
addTool, clear, embedding, inputsLog, instructions, perform, prompt, setWorkingDir, usage
-
Field Details
-
AUTH_URL_PROP_NAME
Configuration key used to override the default token endpoint.- See Also:
-
OPENAI_API_KEY
Configuration/environment key used by OpenAI-compatible clients to provide the API key.For CodeMie this value is set to the retrieved OAuth 2.0 access token.
- See Also:
-
AUTH_URL
Default OpenID Connect token endpoint for CodeMie.Can be overridden via the
AUTH_URLconfiguration key.- See Also:
-
BASE_URL
Base URL for the CodeMie Code Assistant API.This base URL is used to configure the underlying OpenAI-compatible client.
- See Also:
-
-
Constructor Details
-
CodeMieProvider
public CodeMieProvider()
-
-
Method Details
-
init
Initializes the provider using configuration values.Required configuration keys:
GENAI_USERNAME– user e-mail or client id.GENAI_PASSWORD– password or client secret.chatModel– model identifier (for examplegpt-4o-mini,gemini-1.5-pro,claude-3-5-sonnet).
Optional configuration keys:
AUTH_URL– token endpoint override.
- Specified by:
initin interfaceGenai- Overrides:
initin classGenaiAdapter- Parameters:
conf- configuration source- Throws:
IllegalArgumentException- if a configuration conflict is detected, authorization fails, or an unsupported model is configured
-
getToken
Requests an OAuth 2.0 access token from the given token endpoint.The request uses
application/x-www-form-urlencodedand selects the grant type based on theusernamevalue:passwordif the username contains"@".client_credentialsotherwise.
- Parameters:
url- token endpoint URLusername- user e-mail (password grant) or client id (client credentials)password- password (password grant) or client secret (client credentials)- Returns:
- the
access_tokenvalue extracted from the response - Throws:
IOException- if the HTTP request fails, returns a non-200 response, or the token cannot be read
-