Class CodeMieProvider
java.lang.Object
org.machanism.machai.ai.provider.GenaiAdapter
org.machanism.machai.ai.provider.impl.CodeMieProvider
- All Implemented Interfaces:
EmbeddingProvider,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 model prefix:
gpt-*(or blank/unspecified) models delegate toOpenAIProviderclaude-*models delegate toAnthropicProvider
-
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.Fields inherited from class org.machanism.machai.ai.provider.GenaiAdapter
provider -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRequests an embedding vector for the given input text.static StringRequests an OAuth 2.0 access token from the given token endpoint.voidinit(String model, Configurator conf) Initializes the provider using configuration values.Methods inherited from class org.machanism.machai.ai.provider.GenaiAdapter
addPrompts, addTools, clear, inputsLog, instructions, perform, prompt, setErrorHandling, setProjectDir, setProvider
-
Field Details
-
AUTH_URL_PROP_NAME
Configuration key used to override the default token endpoint.- 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()Creates a CodeMie provider instance.
-
-
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.model– 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 interfaceEmbeddingProvider- Specified by:
initin interfaceGenai- Overrides:
initin classGenaiAdapter- Parameters:
model- the model identifier or name to useconf- configuration sourceconfig- 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
-
embedding
Requests an embedding vector for the given input text.- Specified by:
embeddingin interfaceEmbeddingProvider- Parameters:
text- input to embeddimensions- number of dimensions requested from the embedding model- Returns:
- embedding as a list of
doublevalues, ornullwhentextisnull
-