Fix ollama server selector [pt 2]

This commit is contained in:
Nexus 2023-11-22 15:53:55 +00:00
parent 3e4f7c043e
commit bc0123be24
Signed by: nex
GPG key ID: 0FA334385D0B689F
2 changed files with 8 additions and 1 deletions

View file

@ -504,7 +504,7 @@ class Events(commands.Cog):
content = message.content content = message.content
if isinstance(key, str): if isinstance(key, str):
regex = re.compile(key, re.IGNORECASE) regex = re.compile(key.casefold(), re.IGNORECASE)
if not regex.search(content): if not regex.search(content):
continue continue
elif isinstance(key, tuple): elif isinstance(key, tuple):

View file

@ -1938,6 +1938,13 @@ class OtherCog(commands.Cog):
def model_is_allowed(model_name: str, srv: dict[str, str | list[str] | int]) -> bool: def model_is_allowed(model_name: str, srv: dict[str, str | list[str] | int]) -> bool:
for pat in srv.get("allow", ['*']): for pat in srv.get("allow", ['*']):
if not fnmatch.fnmatch(model_name.casefold(), pat.casefold()): if not fnmatch.fnmatch(model_name.casefold(), pat.casefold()):
print(
"Server %r does not support %r (only %r.)" % (
srv['name'],
model_name,
', '.join(srv['allow'])
)
)
return False return False
return True return True