All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.codemodder.plugins.llm.LLMServiceModule Maven / Gradle / Ivy

There is a newer version: 0.97.6
Show newest version
package io.codemodder.plugins.llm;

import com.google.inject.AbstractModule;

/** Provides configured LLM services. */
public final class LLMServiceModule extends AbstractModule {

  private static final String TOKEN_NAME = "CODEMODDER_OPENAI_API_KEY";

  @Override
  protected void configure() {
    bind(OpenAIService.class).toProvider(() -> new OpenAIService(getToken()));
  }

  private String getToken() {
    String token = System.getenv(TOKEN_NAME);
    if (token == null) {
      throw new IllegalArgumentException(TOKEN_NAME + " environment variable must be set");
    }
    return token;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy