Temporary agents and chats

This commit is contained in:
Shivering Ocelot committed 2026-04-16 15:16:03 -05:00
1 parent fe596761dc
commit e07f8ee05f
15 files changed
+447 -172

No files matched your search

+25 -38
View File
@@ -51,48 +51,33 @@ class ExpertAgent(Agent):
if prompt:
messages.append(LlamaMessage("user", prompt))
model = self.config['model']
model_id = self.config['model']
db_model = await self.app.get_model(model_id)
model_engine = db_model.value["engine"]
if type(model) is int:
db_model = await self.app.get_model(model)
model_engine = db_model.value["engine"]
opts = {}
if 'temperature' in self.config:
opts['temperature'] = self.config['temperature']
if 'repetition_penalty' in self.config:
opts['repetition_penalty'] = self.config['repetition_penalty']
if model_engine == "llama-cpp":
response = await inference.local_chat_completion(
self.app,
messages,
model=db_model.value['model'],
opts=opts,
)
elif model_engine == "replicate":
if 'parameters' in db_model:
opts['parameters'] = db_model['parameters']
opts = {}
if 'temperature' in self.config:
opts['temperature'] = self.config['temperature']
if 'repetition_penalty' in self.config:
opts['repetition_penalty'] = self.config['repetition_penalty']
if model_engine == "llama-cpp":
response = await inference.local_chat_completion(
self.app,
messages,
model=db_model.value['model'],
opts=opts,
)
response = await inference.replicate_completion(self.app, messages, model=db_model.value['model'], opts=opts)
return response
elif model_engine == "replicate":
if 'parameters' in db_model:
opts['parameters'] = db_model['parameters']
response = await inference.replicate_completion(self.app, messages, model=db_model.value['model'], opts=opts)
else:
raise Exception("Unsuported model: " + repr(db_model.value))
elif model.startswith("ollama:"):
response = await inference.ollama_chat_completion(self.app, messages, model=model[7:])
elif model == "qwen-big":
response = await inference.replicate_qwen_completion(self.app, messages, model=inference.Models.qwen3_235b)
elif model == "qwen-small":
response = await inference.replicate_qwen_completion(self.app, messages, model=inference.Models.qwen3_8b)
elif model == "llama-big":
response = await inference.replicate_llama_completion(self.app, messages, model=inference.Models.llama_70b)
elif model == "llama-small":
response = await inference.replicate_llama_completion(self.app, messages, model=inference.Models.llama_8b)
elif model_engine == "ollama":
response = await inference.ollama_chat_completion(self.app, messages, model=db_model.value['model'], opts=opts)
else:
# An error here is questionable, model is user configurable
raise Exception("Unkonwn agent model: " + model)
raise Exception("Unsuported model: " + repr(db_model.value))
return response
@@ -108,6 +93,8 @@ class ExpertAgent(Agent):
return 'assistant'
elif sender == 'user':
return 'user'
elif sender.startswith("tmp-"):
return 'assistant'
else:
raise Exception("Unsupported sender: " + sender)