mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2026-04-07 15:43:49 +00:00
API: add instruction_template support to the model load endpoint
This commit is contained in:
parent
4d6230a944
commit
c26ffdd24c
5 changed files with 38 additions and 7 deletions
|
|
@ -1,7 +1,8 @@
|
|||
from modules import loaders, shared
|
||||
from modules.logging_colors import logger
|
||||
from modules.LoRA import add_lora_to_model
|
||||
from modules.models import load_model, unload_model
|
||||
from modules.models_settings import get_model_metadata, update_model_parameters
|
||||
from modules.models_settings import get_model_metadata, load_instruction_template, update_model_parameters
|
||||
from modules.utils import get_available_loras, get_available_models
|
||||
|
||||
|
||||
|
|
@ -69,6 +70,13 @@ def _load_model(data):
|
|||
|
||||
shared.model, shared.tokenizer = load_model(model_name)
|
||||
|
||||
if data.get("instruction_template_str") is not None:
|
||||
shared.settings['instruction_template_str'] = data["instruction_template_str"]
|
||||
logger.info("INSTRUCTION TEMPLATE: set to custom Jinja2 string")
|
||||
elif data.get("instruction_template") is not None:
|
||||
shared.settings['instruction_template_str'] = load_instruction_template(data["instruction_template"])
|
||||
logger.info(f"INSTRUCTION TEMPLATE: {data['instruction_template']}")
|
||||
|
||||
|
||||
def list_loras():
|
||||
return {'lora_names': get_available_loras()[1:]}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue