Merge pull request #198 from db0/soft_prompts_list

Adds /config/soft_prompts_list API endpoint
This commit is contained in:
henk717 2022-09-01 16:35:08 +02:00 committed by GitHub
commit 05a4695ad2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9679,6 +9679,32 @@ def get_config_soft_prompt():
"""
return {"value": vars.spfilename.strip()}
class SoftPromptsListSchema(KoboldSchema):
values: List[SoftPromptSettingSchema] = fields.List(fields.Nested(SoftPromptSettingSchema), required=True, metadata={"description": "Array of available softprompts."})
@api_v1.get("/config/soft_prompts_list")
@api_schema_wrap
def get_config_soft_prompts_list():
"""---
get:
summary: Retrieve all available softprompt filenames
tags:
- config
responses:
200:
description: Successful request
content:
application/json:
schema: SoftPromptsListSchema
example:
values: []
"""
splist = []
for sp in fileops.getspfiles(vars.modeldim):
splist.append({"value":sp["filename"]})
return {"values": splist}
@api_v1.put("/config/soft_prompt")
@api_schema_wrap
def put_config_soft_prompt(body: SoftPromptSettingSchema):