mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Add Lua API for story chunks
This commit is contained in:
18
aiserver.py
18
aiserver.py
@ -1120,6 +1120,23 @@ def lua_resend_settings():
|
||||
settingschanged()
|
||||
refresh_settings()
|
||||
|
||||
#==================================================================#
|
||||
# Set story chunk text and delete the chunk if the new chunk is empty
|
||||
#==================================================================#
|
||||
def lua_set_chunk(k, v):
|
||||
assert type(k) in (int, None) and type(v) is str
|
||||
assert k >= 0
|
||||
assert k != 0 or len(v) != 0
|
||||
if(len(v) == 0):
|
||||
print(colors.PURPLE + f"[USERPLACEHOLDER] deleted story chunk {k}" + colors.END)
|
||||
inlinedelete(k)
|
||||
else:
|
||||
if(k == 0):
|
||||
print(colors.PURPLE + f"[USERPLACEHOLDER] edited prompt chunk" + colors.END)
|
||||
else:
|
||||
print(colors.PURPLE + f"[USERPLACEHOLDER] edited story chunk {k}" + colors.END)
|
||||
inlineedit(k, v)
|
||||
|
||||
#==================================================================#
|
||||
#
|
||||
#==================================================================#
|
||||
@ -1163,6 +1180,7 @@ bridged = {
|
||||
"get_setting": lua_get_setting,
|
||||
"set_setting": lua_set_setting,
|
||||
"resend_settings": lua_resend_settings,
|
||||
"set_chunk": lua_set_chunk,
|
||||
"vars": vars,
|
||||
}
|
||||
try:
|
||||
|
Reference in New Issue
Block a user