Apply a seed to the threads
This commit is contained in:
parent
d883f4044b
commit
6600f49ddf
1 changed files with 12 additions and 5 deletions
|
@ -76,6 +76,7 @@ class ChatHistory:
|
||||||
key = os.urandom(3).hex()
|
key = os.urandom(3).hex()
|
||||||
self._internal[key] = {
|
self._internal[key] = {
|
||||||
"member": member,
|
"member": member,
|
||||||
|
"seed": round(time.time())
|
||||||
"messages": []
|
"messages": []
|
||||||
}
|
}
|
||||||
with open("./assets/ollama-prompt.txt") as file:
|
with open("./assets/ollama-prompt.txt") as file:
|
||||||
|
@ -121,6 +122,10 @@ class ChatHistory:
|
||||||
"""
|
"""
|
||||||
return self._internal[thread]["messages"].copy() # copy() makes it immutable.
|
return self._internal[thread]["messages"].copy() # copy() makes it immutable.
|
||||||
|
|
||||||
|
def get_thread(self, thread: str) -> dict[str, list[dict[str, str]] | discord.Member | int]:
|
||||||
|
"""Gets a copy of an entire thread"""
|
||||||
|
return self._internal[thread].copy()
|
||||||
|
|
||||||
|
|
||||||
SERVER_KEYS = list(CONFIG["ollama"].keys())
|
SERVER_KEYS = list(CONFIG["ollama"].keys())
|
||||||
|
|
||||||
|
@ -415,11 +420,6 @@ class Ollama(commands.Cog):
|
||||||
await ctx.respond(embed=embed, view=view)
|
await ctx.respond(embed=embed, view=view)
|
||||||
self.log.debug("Beginning to generate response with key %r.", key)
|
self.log.debug("Beginning to generate response with key %r.", key)
|
||||||
|
|
||||||
params = {}
|
|
||||||
if give_acid is True:
|
|
||||||
params["temperature"] = 500
|
|
||||||
params["top_k"] = 500
|
|
||||||
params["top_p"] = 500
|
|
||||||
|
|
||||||
if context is None or context in self.contexts:
|
if context is None or context in self.contexts:
|
||||||
context = self.history.create_thread(ctx.user)
|
context = self.history.create_thread(ctx.user)
|
||||||
|
@ -431,6 +431,13 @@ class Ollama(commands.Cog):
|
||||||
if image_data:
|
if image_data:
|
||||||
user_message["images"] = [image_data]
|
user_message["images"] = [image_data]
|
||||||
messages.append(user_message)
|
messages.append(user_message)
|
||||||
|
|
||||||
|
params = {"seed": self.history.get_thread(context)["seed"]}
|
||||||
|
if give_acid is True:
|
||||||
|
params["temperature"] = 500
|
||||||
|
params["top_k"] = 500
|
||||||
|
params["top_p"] = 500
|
||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
"model": model,
|
"model": model,
|
||||||
"stream": True,
|
"stream": True,
|
||||||
|
|
Loading…
Reference in a new issue