mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-19 18:16:34 +01:00
Fix ollama server selector [pt 4]
This commit is contained in:
parent
c785c22800
commit
fd300e8a51
1 changed files with 13 additions and 11 deletions
|
@ -2058,11 +2058,12 @@ class OtherCog(commands.Cog):
|
||||||
url=f"http://{host}",
|
url=f"http://{host}",
|
||||||
icon_url="https://cdn.discordapp.com/emojis/1101463077586735174.gif"
|
icon_url="https://cdn.discordapp.com/emojis/1101463077586735174.gif"
|
||||||
)
|
)
|
||||||
embed.set_footer(
|
FOOTER_TEXT = "Powered by Ollama • Using server {} ({})".format(
|
||||||
text="Using server {} ({})".format(
|
|
||||||
host,
|
host,
|
||||||
servers.get(host, H_DEFAULT)['name']
|
servers.get(host, H_DEFAULT)['name']
|
||||||
)
|
)
|
||||||
|
embed.set_footer(
|
||||||
|
text=FOOTER_TEXT
|
||||||
)
|
)
|
||||||
|
|
||||||
msg = await ctx.respond(embed=embed, ephemeral=False)
|
msg = await ctx.respond(embed=embed, ephemeral=False)
|
||||||
|
@ -2083,7 +2084,7 @@ class OtherCog(commands.Cog):
|
||||||
title="Failed to GET /tags. Offline?",
|
title="Failed to GET /tags. Offline?",
|
||||||
description=error,
|
description=error,
|
||||||
colour=discord.Colour.red()
|
colour=discord.Colour.red()
|
||||||
)
|
).set_footer(text=FOOTER_TEXT)
|
||||||
)
|
)
|
||||||
except httpx.TransportError as e:
|
except httpx.TransportError as e:
|
||||||
return await msg.edit(
|
return await msg.edit(
|
||||||
|
@ -2093,7 +2094,7 @@ class OtherCog(commands.Cog):
|
||||||
host, str(e)
|
host, str(e)
|
||||||
),
|
),
|
||||||
colour=discord.Colour.red()
|
colour=discord.Colour.red()
|
||||||
)
|
).set_footer(text=FOOTER_TEXT)
|
||||||
)
|
)
|
||||||
# get models
|
# get models
|
||||||
try:
|
try:
|
||||||
|
@ -2104,7 +2105,7 @@ class OtherCog(commands.Cog):
|
||||||
description=str(e),
|
description=str(e),
|
||||||
colour=discord.Colour.red()
|
colour=discord.Colour.red()
|
||||||
)
|
)
|
||||||
embed.set_footer(text="Using server {} ({})".format(host, servers.get(host, "Other")))
|
embed.set_footer(text=FOOTER_TEXT)
|
||||||
return await msg.edit(embed=embed)
|
return await msg.edit(embed=embed)
|
||||||
if response.status_code == 404:
|
if response.status_code == 404:
|
||||||
embed.title = f"Downloading {model}"
|
embed.title = f"Downloading {model}"
|
||||||
|
@ -2124,7 +2125,7 @@ class OtherCog(commands.Cog):
|
||||||
colour=discord.Colour.red(),
|
colour=discord.Colour.red(),
|
||||||
url=str(response.url)
|
url=str(response.url)
|
||||||
)
|
)
|
||||||
embed.set_footer(text="Using server {} ({})".format(host, servers.get(host, "Other")))
|
embed.set_footer(text=FOOTER_TEXT)
|
||||||
return await msg.edit(embed=embed)
|
return await msg.edit(embed=embed)
|
||||||
lines: dict[str, str] = {}
|
lines: dict[str, str] = {}
|
||||||
last_edit = time()
|
last_edit = time()
|
||||||
|
@ -2159,7 +2160,7 @@ class OtherCog(commands.Cog):
|
||||||
colour=discord.Colour.red(),
|
colour=discord.Colour.red(),
|
||||||
url=str(response.url)
|
url=str(response.url)
|
||||||
)
|
)
|
||||||
embed.set_footer(text="Using server {} ({})".format(host, servers.get(host, "Other")))
|
embed.set_footer(text=FOOTER_TEXT)
|
||||||
return await msg.edit(embed=embed)
|
return await msg.edit(embed=embed)
|
||||||
|
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
|
@ -2168,7 +2169,7 @@ class OtherCog(commands.Cog):
|
||||||
colour=discord.Colour.blurple(),
|
colour=discord.Colour.blurple(),
|
||||||
timestamp=discord.utils.utcnow()
|
timestamp=discord.utils.utcnow()
|
||||||
)
|
)
|
||||||
embed.set_footer(text=f"Powered by Ollama • {host} ({servers.get(host, 'Other')})")
|
embed.set_footer(text=FOOTER_TEXT)
|
||||||
await msg.edit(embed=embed)
|
await msg.edit(embed=embed)
|
||||||
async with ctx.channel.typing():
|
async with ctx.channel.typing():
|
||||||
payload = {
|
payload = {
|
||||||
|
@ -2193,7 +2194,7 @@ class OtherCog(commands.Cog):
|
||||||
description=f"HTTP {response.status_code}:\n```{error or '<no body>'}\n```",
|
description=f"HTTP {response.status_code}:\n```{error or '<no body>'}\n```",
|
||||||
colour=discord.Colour.red()
|
colour=discord.Colour.red()
|
||||||
)
|
)
|
||||||
embed.set_footer(text="Using server {} ({})".format(host, servers.get(host, "Other")))
|
embed.set_footer(text=FOOTER_TEXT)
|
||||||
return await msg.edit(embed=embed)
|
return await msg.edit(embed=embed)
|
||||||
self.ollama_locks[msg] = asyncio.Event()
|
self.ollama_locks[msg] = asyncio.Event()
|
||||||
view = self.OllamaKillSwitchView(ctx, msg)
|
view = self.OllamaKillSwitchView(ctx, msg)
|
||||||
|
@ -2296,6 +2297,7 @@ class OtherCog(commands.Cog):
|
||||||
value=key,
|
value=key,
|
||||||
inline=True
|
inline=True
|
||||||
)
|
)
|
||||||
|
embed.set_footer(text=FOOTER_TEXT)
|
||||||
await msg.edit(content=None, embed=embed, view=None)
|
await msg.edit(content=None, embed=embed, view=None)
|
||||||
self.ollama_locks.pop(msg, None)
|
self.ollama_locks.pop(msg, None)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue