mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-19 18:16:34 +01:00
Set faststart flag to all M4A files
This commit is contained in:
parent
c18349dffe
commit
2b9b2ad778
10 changed files with 92 additions and 58 deletions
BIN
assets/china.m4a
BIN
assets/china.m4a
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
assets/hair.m4a
BIN
assets/hair.m4a
Binary file not shown.
Binary file not shown.
BIN
assets/pork.m4a
BIN
assets/pork.m4a
Binary file not shown.
Binary file not shown.
BIN
assets/tea.m4a
BIN
assets/tea.m4a
Binary file not shown.
150
cogs/other.py
150
cogs/other.py
|
@ -1,5 +1,6 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import base64
|
import base64
|
||||||
|
import fnmatch
|
||||||
import functools
|
import functools
|
||||||
import glob
|
import glob
|
||||||
import io
|
import io
|
||||||
|
@ -1897,70 +1898,103 @@ class OtherCog(commands.Cog):
|
||||||
return await ctx.respond(":x: Context not found in cache.")
|
return await ctx.respond(":x: Context not found in cache.")
|
||||||
context = self.context_cache[context]
|
context = self.context_cache[context]
|
||||||
|
|
||||||
content = None
|
|
||||||
RESTRICTED_SERVERS = (
|
|
||||||
"100.106.34.86:11434",
|
|
||||||
"100.66.187.46:11434"
|
|
||||||
)
|
|
||||||
try_hosts = {
|
|
||||||
"100.106.34.86:11434": "NexTop",
|
|
||||||
"ollama.shronk.net": "Alibaba Cloud",
|
|
||||||
"100.66.187.46:11434": "NexBox",
|
|
||||||
}
|
|
||||||
model = model.casefold()
|
model = model.casefold()
|
||||||
|
try:
|
||||||
|
model.split(":", 1)
|
||||||
|
except ValueError:
|
||||||
|
model = model + ":latest"
|
||||||
|
|
||||||
if server == "auto":
|
servers = {
|
||||||
async with httpx.AsyncClient(follow_redirects=True) as client:
|
"100.106.34.86:11434": {
|
||||||
for host in try_hosts.keys():
|
"name": "NexTop",
|
||||||
try:
|
"allow": [
|
||||||
response = await client.get(
|
"orca-mini:latest",
|
||||||
f"http://{host}/api/tags",
|
"orca-mini:3b",
|
||||||
)
|
"orca-mini:7b",
|
||||||
response.raise_for_status()
|
"llama2:latest",
|
||||||
except (httpx.TransportError, httpx.NetworkError, httpx.HTTPStatusError):
|
"llama2-uncensored:latest",
|
||||||
continue
|
"codellama:latest",
|
||||||
else:
|
"codellama:python",
|
||||||
break
|
"codellama:instruct",
|
||||||
else:
|
],
|
||||||
return await ctx.respond(":x: No servers available.")
|
"owner": 421698654189912064
|
||||||
else:
|
},
|
||||||
try:
|
"ollama.shronk.net:11434": {
|
||||||
try:
|
"name": "Alibaba Cloud",
|
||||||
server, port = server.split(":", 1)
|
"allow": ["*"],
|
||||||
port = int(port)
|
"owner": 1019233057519177778,
|
||||||
except ValueError:
|
},
|
||||||
port = 11434
|
"100.66.187.46:11434": {
|
||||||
server = ipaddress.ip_address(server)
|
"name": "NexBox",
|
||||||
if not isinstance(server, ipaddress.IPv4Address):
|
"restrict-to": [
|
||||||
raise ValueError
|
"orca-mini:latest",
|
||||||
server = "%s:%s" % (server, port)
|
"orca-mini:3b",
|
||||||
except ValueError:
|
"orca-mini:7b",
|
||||||
try:
|
],
|
||||||
if not server.startswith("http"):
|
"owner": 421698654189912064
|
||||||
server = "http://" + server
|
},
|
||||||
server = urlparse(server)
|
}
|
||||||
if not server.netloc:
|
|
||||||
raise ValueError
|
|
||||||
except ValueError:
|
|
||||||
return await ctx.respond(f":x: Failed to parse {server!r} as a domain/IPv4.")
|
|
||||||
else:
|
|
||||||
_server = server
|
|
||||||
server = _server.netloc
|
|
||||||
port = _server.port or 443
|
|
||||||
server = "%s:%s" % (server, port)
|
|
||||||
|
|
||||||
host = server
|
class ServerSelector(discord.ui.View):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(
|
||||||
|
disable_on_timeout=True
|
||||||
|
)
|
||||||
|
self.chosen_server = None
|
||||||
|
|
||||||
if host in RESTRICTED_SERVERS:
|
@discord.ui.select(
|
||||||
if not await self.bot.is_owner(ctx.author):
|
placeholder="Choose a server.",
|
||||||
if not model.startswith("orca-mini"):
|
custom_id="select",
|
||||||
await ctx.respond(
|
options=[
|
||||||
":warning: You can only use `orca-mini` models.",
|
discord.SelectOption(
|
||||||
delete_after=30,
|
label="%s (%s)" % (y['name'], x),
|
||||||
ephemeral=True
|
label=x
|
||||||
)
|
)
|
||||||
model = "orca-mini"
|
for x, y in servers.items()
|
||||||
|
if fnmatch.fnmatch(model, y.get("restrict-to", ['*']))
|
||||||
|
] + [
|
||||||
|
discord.SelectOption(
|
||||||
|
label="Custom",
|
||||||
|
value="custom"
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
async def select_callback(self, item: discord.ui.Select, interaction: discord.Interaction):
|
||||||
|
if item.values[0] == "custom":
|
||||||
|
class ServerSelectionModal(discord.ui.Modal):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(
|
||||||
|
discord.ui.InputText(
|
||||||
|
label="Domain/IP",
|
||||||
|
placeholder="Enter server",
|
||||||
|
min_length=1,
|
||||||
|
max_length=4000,
|
||||||
|
style=discord.InputTextStyle.short,
|
||||||
|
),
|
||||||
|
discord.ui.InputText(
|
||||||
|
label="Port (only 443 is HTTPS)",
|
||||||
|
placeholder="11434",
|
||||||
|
min_length=2,
|
||||||
|
max_length=5,
|
||||||
|
style=discord.InputTextStyle.short,
|
||||||
|
value="11434"
|
||||||
|
),
|
||||||
|
title="Enter server details",
|
||||||
|
timeout=120
|
||||||
|
)
|
||||||
|
self.hostname = None
|
||||||
|
self.port = None
|
||||||
|
|
||||||
|
async def callback(self, _interaction: discord.Interaction):
|
||||||
|
await _interaction.response.defer()
|
||||||
|
self.stop()
|
||||||
|
|
||||||
|
_modal = ServerSelectionModal()
|
||||||
|
await interaction.response.send_modal(_modal)
|
||||||
|
await _modal.wait()
|
||||||
|
if not all()
|
||||||
|
|
||||||
|
content = None
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
colour=discord.Colour.greyple()
|
colour=discord.Colour.greyple()
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue