memoize load_character to speed up the chat API
This commit is contained in:
parent
8b9ba3d7b4
commit
4d94a111d4
2 changed files with 9 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
import ast
|
||||
import base64
|
||||
import copy
|
||||
import functools
|
||||
import io
|
||||
import json
|
||||
import re
|
||||
|
@ -568,6 +569,11 @@ def load_character(character, name1, name2, instruct=False):
|
|||
return name1, name2, picture, greeting, context, repr(turn_template)[1:-1]
|
||||
|
||||
|
||||
@functools.cache
|
||||
def load_character_memoized(character, name1, name2, instruct=False):
|
||||
return load_character(character, name1, name2, instruct=instruct)
|
||||
|
||||
|
||||
def upload_character(json_file, img, tavern=False):
|
||||
json_file = json_file if type(json_file) == str else json_file.decode('utf-8')
|
||||
data = json.loads(json_file)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue