mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-02-17 12:10:49 +01:00
Change behaviour of disable_input/output_formatting
This commit is contained in:
parent
bd703cd36a
commit
cd7ff2b141
64
aiserver.py
64
aiserver.py
@ -583,7 +583,7 @@ tags = [
|
|||||||
api_version = None # This gets set automatically so don't change this value
|
api_version = None # This gets set automatically so don't change this value
|
||||||
|
|
||||||
api_v1 = KoboldAPISpec(
|
api_v1 = KoboldAPISpec(
|
||||||
version="1.1.2",
|
version="1.1.3",
|
||||||
prefixes=["/api/v1", "/api/latest"],
|
prefixes=["/api/v1", "/api/latest"],
|
||||||
tags=tags,
|
tags=tags,
|
||||||
)
|
)
|
||||||
@ -5087,9 +5087,6 @@ def getnewcontent(txt):
|
|||||||
# Applies chosen formatting options to text submitted to AI
|
# Applies chosen formatting options to text submitted to AI
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
def applyinputformatting(txt):
|
def applyinputformatting(txt):
|
||||||
if(vars.disable_input_formatting):
|
|
||||||
return txt
|
|
||||||
|
|
||||||
# Add sentence spacing
|
# Add sentence spacing
|
||||||
if(vars.formatoptns["frmtadsnsp"]):
|
if(vars.formatoptns["frmtadsnsp"]):
|
||||||
txt = utils.addsentencespacing(txt, vars)
|
txt = utils.addsentencespacing(txt, vars)
|
||||||
@ -5103,9 +5100,6 @@ def applyoutputformatting(txt):
|
|||||||
# Use standard quotes and apostrophes
|
# Use standard quotes and apostrophes
|
||||||
txt = utils.fixquotes(txt)
|
txt = utils.fixquotes(txt)
|
||||||
|
|
||||||
if(vars.disable_output_formatting):
|
|
||||||
return txt
|
|
||||||
|
|
||||||
# Adventure mode clipping of all characters after '>'
|
# Adventure mode clipping of all characters after '>'
|
||||||
if(vars.adventure):
|
if(vars.adventure):
|
||||||
txt = vars.acregex_ai.sub('', txt)
|
txt = vars.acregex_ai.sub('', txt)
|
||||||
@ -7085,13 +7079,13 @@ class GenerationInputSchema(SamplerSettingsSchema):
|
|||||||
max_length: int = fields.Integer(validate=validate.Range(min=1, max=512), metadata={"description": "Number of tokens to generate."})
|
max_length: int = fields.Integer(validate=validate.Range(min=1, max=512), metadata={"description": "Number of tokens to generate."})
|
||||||
max_context_length: int = fields.Integer(validate=validate.Range(min=512, max=2048), metadata={"description": "Maximum number of tokens to send to the model."})
|
max_context_length: int = fields.Integer(validate=validate.Range(min=512, max=2048), metadata={"description": "Maximum number of tokens to send to the model."})
|
||||||
n: int = fields.Integer(validate=validate.Range(min=1, max=5), metadata={"description": "Number of outputs to generate."})
|
n: int = fields.Integer(validate=validate.Range(min=1, max=5), metadata={"description": "Number of outputs to generate."})
|
||||||
disable_output_formatting: bool = fields.Boolean(load_default=True, metadata={"description": "When enabled, disables all output formatting options, overriding their individual enabled/disabled states."})
|
disable_output_formatting: bool = fields.Boolean(load_default=True, metadata={"description": "When enabled, all output formatting options default to `false` instead of the value in the KoboldAI GUI."})
|
||||||
frmttriminc: Optional[bool] = fields.Boolean(metadata={"description": "Output formatting option. When enabled, removes some characters from the end of the output such that the output doesn't end in the middle of a sentence. If the output is less than one sentence long, does nothing.\n\nWARNING: This has no effect unless `disable_output_formatting` is set to `false`."})
|
frmttriminc: Optional[bool] = fields.Boolean(metadata={"description": "Output formatting option. When enabled, removes some characters from the end of the output such that the output doesn't end in the middle of a sentence. If the output is less than one sentence long, does nothing.\n\nIf `disable_output_formatting` is `true`, this defaults to `false` instead of the value in the KoboldAI GUI."})
|
||||||
frmtrmblln: Optional[bool] = fields.Boolean(metadata={"description": "Output formatting option. When enabled, replaces all occurrences of two or more consecutive newlines in the output with one newline.\n\nWARNING: This has no effect unless `disable_output_formatting` is set to `false`."})
|
frmtrmblln: Optional[bool] = fields.Boolean(metadata={"description": "Output formatting option. When enabled, replaces all occurrences of two or more consecutive newlines in the output with one newline.\n\nIf `disable_output_formatting` is `true`, this defaults to `false` instead of the value in the KoboldAI GUI."})
|
||||||
frmtrmspch: Optional[bool] = fields.Boolean(metadata={"description": "Output formatting option. When enabled, removes `#/@%{}+=~|\^<>` from the output.\n\nWARNING: This has no effect unless `disable_output_formatting` is set to `false`."})
|
frmtrmspch: Optional[bool] = fields.Boolean(metadata={"description": "Output formatting option. When enabled, removes `#/@%{}+=~|\^<>` from the output.\n\nIf `disable_output_formatting` is `true`, this defaults to `false` instead of the value in the KoboldAI GUI."})
|
||||||
singleline: Optional[bool] = fields.Boolean(metadata={"description": "Output formatting option. When enabled, removes everything after the first line of the output, including the newline.\n\nWARNING: This has no effect unless `disable_output_formatting` is set to `false`."})
|
singleline: Optional[bool] = fields.Boolean(metadata={"description": "Output formatting option. When enabled, removes everything after the first line of the output, including the newline.\n\nIf `disable_output_formatting` is `true`, this defaults to `false` instead of the value in the KoboldAI GUI."})
|
||||||
disable_input_formatting: bool = fields.Boolean(load_default=True, metadata={"description": "When enabled, disables all input formatting options, overriding their individual enabled/disabled states."})
|
disable_input_formatting: bool = fields.Boolean(load_default=True, metadata={"description": "When enabled, all input formatting options default to `false` instead of the value in the KoboldAI GUI"})
|
||||||
frmtadsnsp: Optional[bool] = fields.Boolean(metadata={"description": "Input formatting option. When enabled, adds a leading space to your input if there is no trailing whitespace at the end of the previous action.\n\nWARNING: This has no effect unless `disable_input_formatting` is set to `false`."})
|
frmtadsnsp: Optional[bool] = fields.Boolean(metadata={"description": "Input formatting option. When enabled, adds a leading space to your input if there is no trailing whitespace at the end of the previous action.\n\nIf `disable_input_formatting` is `true`, this defaults to `false` instead of the value in the KoboldAI GUI."})
|
||||||
|
|
||||||
class GenerationResultSchema(KoboldSchema):
|
class GenerationResultSchema(KoboldSchema):
|
||||||
text: str = fields.String(required=True, metadata={"description": "Generated output as plain text."})
|
text: str = fields.String(required=True, metadata={"description": "Generated output as plain text."})
|
||||||
@ -7180,25 +7174,25 @@ def _generate_text(body: GenerationInputSchema):
|
|||||||
"type": "service_unavailable",
|
"type": "service_unavailable",
|
||||||
}}), mimetype="application/json", status=503))
|
}}), mimetype="application/json", status=503))
|
||||||
mapping = {
|
mapping = {
|
||||||
"rep_pen": ("vars", "rep_pen"),
|
"disable_input_formatting": ("vars", "disable_input_formatting", None),
|
||||||
"rep_pen_range": ("vars", "rep_pen_range"),
|
"disable_output_formatting": ("vars", "disable_output_formatting", None),
|
||||||
"rep_pen_slope": ("vars", "rep_pen_slope"),
|
"rep_pen": ("vars", "rep_pen", None),
|
||||||
"top_k": ("vars", "top_k"),
|
"rep_pen_range": ("vars", "rep_pen_range", None),
|
||||||
"top_a": ("vars", "top_a"),
|
"rep_pen_slope": ("vars", "rep_pen_slope", None),
|
||||||
"top_p": ("vars", "top_p"),
|
"top_k": ("vars", "top_k", None),
|
||||||
"tfs": ("vars", "tfs"),
|
"top_a": ("vars", "top_a", None),
|
||||||
"typical": ("vars", "typical"),
|
"top_p": ("vars", "top_p", None),
|
||||||
"temperature": ("vars", "temp"),
|
"tfs": ("vars", "tfs", None),
|
||||||
"frmtadnsp": ("vars.formatoptns", "@frmtadnsp"),
|
"typical": ("vars", "typical", None),
|
||||||
"frmttriminc": ("vars.formatoptns", "@frmttriminc"),
|
"temperature": ("vars", "temp", None),
|
||||||
"frmtrmblln": ("vars.formatoptns", "@frmtrmblln"),
|
"frmtadsnsp": ("vars.formatoptns", "@frmtadsnsp", "input"),
|
||||||
"frmtrmspch": ("vars.formatoptns", "@frmtrmspch"),
|
"frmttriminc": ("vars.formatoptns", "@frmttriminc", "output"),
|
||||||
"singleline": ("vars.formatoptns", "@singleline"),
|
"frmtrmblln": ("vars.formatoptns", "@frmtrmblln", "output"),
|
||||||
"disable_input_formatting": ("vars", "disable_input_formatting"),
|
"frmtrmspch": ("vars.formatoptns", "@frmtrmspch", "output"),
|
||||||
"disable_output_formatting": ("vars", "disable_output_formatting"),
|
"singleline": ("vars.formatoptns", "@singleline", "output"),
|
||||||
"max_length": ("vars", "genamt"),
|
"max_length": ("vars", "genamt", None),
|
||||||
"max_context_length": ("vars", "max_length"),
|
"max_context_length": ("vars", "max_length", None),
|
||||||
"n": ("vars", "numseqs"),
|
"n": ("vars", "numseqs", None),
|
||||||
}
|
}
|
||||||
saved_settings = {}
|
saved_settings = {}
|
||||||
set_aibusy(1)
|
set_aibusy(1)
|
||||||
@ -7212,6 +7206,10 @@ def _generate_text(body: GenerationInputSchema):
|
|||||||
vars.output_streaming = False
|
vars.output_streaming = False
|
||||||
for key, entry in mapping.items():
|
for key, entry in mapping.items():
|
||||||
obj = {"vars": vars, "vars.formatoptns": vars.formatoptns}[entry[0]]
|
obj = {"vars": vars, "vars.formatoptns": vars.formatoptns}[entry[0]]
|
||||||
|
if entry[2] == "input" and vars.disable_input_formatting and not hasattr(body, key):
|
||||||
|
setattr(body, key, False)
|
||||||
|
if entry[2] == "output" and vars.disable_output_formatting and not hasattr(body, key):
|
||||||
|
setattr(body, key, False)
|
||||||
if getattr(body, key, None) is not None:
|
if getattr(body, key, None) is not None:
|
||||||
if entry[1].startswith("@"):
|
if entry[1].startswith("@"):
|
||||||
saved_settings[key] = obj[entry[1][1:]]
|
saved_settings[key] = obj[entry[1][1:]]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user