Skip to content

[Android] Add API to use new config #10346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ public LlmModule(int modelType, String modulePath, String tokenizerPath, float t
mHybridData = initHybrid(modelType, modulePath, tokenizerPath, temperature, null);
}

/** Constructs a LLM Module for a model with the given LlmModuleConfig */
public LlmModule(LlmModuleConfig config) {
mHybridData =
initHybrid(
config.getModelType(),
config.getModulePath(),
config.getTokenizerPath(),
config.getTemperature(),
config.getDataPath());
}

public void resetNative() {
mHybridData.resetNative();
}
Expand Down Expand Up @@ -107,6 +118,19 @@ public int generate(String prompt, int seqLen, LlmCallback llmCallback, boolean
return generate(null, 0, 0, 0, prompt, seqLen, llmCallback, echo);
}

/**
* Start generating tokens from the module.
*
* @param prompt Input prompt
* @param config the config for generation
* @param llmCallback callback object to receive results
*/
public int generate(String prompt, LlmGenerationConfig config, LlmCallback llmCallback) {
int seqLen = config.getSeqLen();
boolean echo = config.isEcho();
return generate(null, 0, 0, 0, prompt, seqLen, llmCallback, echo);
}

/**
* Start generating tokens from the module.
*
Expand Down
Loading