add ask_ai message command
This commit is contained in:
parent
0cc5ce7150
commit
5ac83dd939
3 changed files with 26 additions and 20 deletions
|
@ -1,6 +0,0 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
|
@ -222,7 +222,7 @@ class FFMeta(commands.Cog):
|
|||
else:
|
||||
await ctx.respond(file=discord.File(file, filename=filename))
|
||||
|
||||
paginator = commands.Paginator(prefix="```", suffix="```")
|
||||
paginator = commands.Paginator()
|
||||
for line in stderr.splitlines():
|
||||
if line.strip().startswith(":"):
|
||||
continue
|
||||
|
|
|
@ -146,6 +146,13 @@ class OllamaChatHandler:
|
|||
if line.get("prompt_eval_count"):
|
||||
self.prompt_eval_count = line["prompt_eval_count"]
|
||||
|
||||
def __enter__(self):
|
||||
self._abort.clear()
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
self._abort.set()
|
||||
|
||||
async def __aiter__(self):
|
||||
async with self.client.post(
|
||||
"/api/chat",
|
||||
|
@ -943,9 +950,13 @@ class Ollama(commands.Cog):
|
|||
|
||||
messages = self.history.get_history(thread)
|
||||
embed = discord.Embed(description=">>> ")
|
||||
async for ln in client.new_chat("orca-mini:3b", messages):
|
||||
embed.description += ln["message"]["content"]
|
||||
if len(embed.description) >= 4032:
|
||||
await ctx.respond(embed=discord.Embed(description="*waiting...*"))
|
||||
last_edit = time.time()
|
||||
with client.new_chat("orca-mini:3b", messages) as handler:
|
||||
async for ln in handler:
|
||||
done = ln.get("done") is True
|
||||
embed.description = ">>> " + handler.result
|
||||
if len(embed.description) >= 4096:
|
||||
break
|
||||
if len(embed.description) >= 3250:
|
||||
embed.colour = discord.Color.gold()
|
||||
|
@ -953,8 +964,9 @@ class Ollama(commands.Cog):
|
|||
else:
|
||||
embed.colour = discord.Color.blurple()
|
||||
embed.set_footer(text="Using server %r" % server, icon_url=CONFIG["ollama"][server].get("icon_url"))
|
||||
if time.time() >= (last_edit + 5.1) or done:
|
||||
await ctx.edit(embed=embed)
|
||||
if ln.get("done"):
|
||||
if done:
|
||||
break
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue