Better log ollama
This commit is contained in:
parent
9924381b0b
commit
419ed8efe4
2 changed files with 22 additions and 5 deletions
|
@ -4,7 +4,9 @@
|
||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="aa6d62a8-d64d-4a60-a85f-8d9fa52b6b49" name="Changes" comment="Fix stupid aiohttp base url req" />
|
<list default="true" id="aa6d62a8-d64d-4a60-a85f-8d9fa52b6b49" name="Changes" comment="Fix ollama">
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/cogs/ollama.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/cogs/ollama.py" afterDir="false" />
|
||||||
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
|
@ -76,7 +78,7 @@
|
||||||
<workItem from="1704296563227" duration="780000" />
|
<workItem from="1704296563227" duration="780000" />
|
||||||
<workItem from="1704317484555" duration="1407000" />
|
<workItem from="1704317484555" duration="1407000" />
|
||||||
<workItem from="1704572901106" duration="125000" />
|
<workItem from="1704572901106" duration="125000" />
|
||||||
<workItem from="1704573038888" duration="5416000" />
|
<workItem from="1704573038888" duration="5748000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="Update gitignore">
|
<task id="LOCAL-00001" summary="Update gitignore">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
|
@ -182,7 +184,15 @@
|
||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1704578291055</updated>
|
<updated>1704578291055</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="14" />
|
<task id="LOCAL-00014" summary="Fix ollama">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1704578625479</created>
|
||||||
|
<option name="number" value="00014" />
|
||||||
|
<option name="presentableId" value="LOCAL-00014" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1704578625479</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="15" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
|
@ -203,6 +213,7 @@
|
||||||
<MESSAGE value="FIx unicode" />
|
<MESSAGE value="FIx unicode" />
|
||||||
<MESSAGE value="Remove top level import" />
|
<MESSAGE value="Remove top level import" />
|
||||||
<MESSAGE value="Fix stupid aiohttp base url req" />
|
<MESSAGE value="Fix stupid aiohttp base url req" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="Fix stupid aiohttp base url req" />
|
<MESSAGE value="Fix ollama" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="Fix ollama" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -144,7 +144,9 @@ class Ollama(commands.Cog):
|
||||||
await ctx.respond(embed=embed)
|
await ctx.respond(embed=embed)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
self.log.debug("Connecting to %r", server_config["base_url"])
|
||||||
async with session.post("/api/show", json={"name": model}) as resp:
|
async with session.post("/api/show", json={"name": model}) as resp:
|
||||||
|
self.log.debug("%r responded.", server_config["base_url"])
|
||||||
if resp.status not in [404, 200]:
|
if resp.status not in [404, 200]:
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
url=resp.url,
|
url=resp.url,
|
||||||
|
@ -166,6 +168,7 @@ class Ollama(commands.Cog):
|
||||||
return await ctx.edit(embed=embed)
|
return await ctx.edit(embed=embed)
|
||||||
|
|
||||||
if resp.status == 404:
|
if resp.status == 404:
|
||||||
|
self.log.debug("Beginning download of %r", model)
|
||||||
def progress_bar(value: float, action: str = None):
|
def progress_bar(value: float, action: str = None):
|
||||||
bar = "\N{large green square}" * round(value / 10)
|
bar = "\N{large green square}" * round(value / 10)
|
||||||
bar += "\N{white large square}" * (10 - len(bar))
|
bar += "\N{white large square}" * (10 - len(bar))
|
||||||
|
@ -207,6 +210,8 @@ class Ollama(commands.Cog):
|
||||||
embed.fields[0].value = progress_bar(percent, line["status"])
|
embed.fields[0].value = progress_bar(percent, line["status"])
|
||||||
await ctx.edit(embed=embed)
|
await ctx.edit(embed=embed)
|
||||||
last_update = time.time()
|
last_update = time.time()
|
||||||
|
else:
|
||||||
|
self.log.debug("Model %r already exists on server.", model)
|
||||||
|
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
title="Generating response...",
|
title="Generating response...",
|
||||||
|
@ -215,6 +220,7 @@ class Ollama(commands.Cog):
|
||||||
timestamp=discord.utils.utcnow()
|
timestamp=discord.utils.utcnow()
|
||||||
)
|
)
|
||||||
await ctx.edit(embed=embed)
|
await ctx.edit(embed=embed)
|
||||||
|
self.log.debug("Beginning to generate response.")
|
||||||
async with session.post(
|
async with session.post(
|
||||||
"/api/generate",
|
"/api/generate",
|
||||||
json={
|
json={
|
||||||
|
@ -242,7 +248,7 @@ class Ollama(commands.Cog):
|
||||||
if line.get("done"):
|
if line.get("done"):
|
||||||
embed.title = "Done!"
|
embed.title = "Done!"
|
||||||
embed.color = discord.Color.green()
|
embed.color = discord.Color.green()
|
||||||
embed.description += line["response"]
|
embed.description += line["response"].strip()
|
||||||
embed.timestamp = discord.utils.utcnow()
|
embed.timestamp = discord.utils.utcnow()
|
||||||
if len(embed.description) >= 4096:
|
if len(embed.description) >= 4096:
|
||||||
embed.description = embed.description[:4093] + "..."
|
embed.description = embed.description[:4093] + "..."
|
||||||
|
|
Loading…
Reference in a new issue