Reimplement replicate inference. Allow model deletion. Implement repetition penalty. Fixes in stream reading.
This commit is contained in:
1 parent
26aa137c98
commit
fe596761dc
10 files changed
+169
-20
No files matched your search
@@ -21,6 +21,7 @@ class ExpertAgent(Agent):
|
||||
AgentField('system_prompt', 'string', default="You are an expert AI assistant."),
|
||||
AgentField('model', 'model_id', default=None),
|
||||
AgentField('temperature', 'number', default=None),
|
||||
AgentField('repetition_penalty', 'number', default=None),
|
||||
]
|
||||
|
||||
def __init__(self, app, data):
|
||||
@@ -55,18 +56,27 @@ class ExpertAgent(Agent):
|
||||
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={
|
||||
'temperature':self.config.get('temperature')
|
||||
}
|
||||
opts=opts,
|
||||
)
|
||||
|
||||
return response
|
||||
elif model_engine == "replicate":
|
||||
response = await inference.replicate_llama_completion(self.app, messages, model=db_model.value['model'])
|
||||
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))
|
||||
|
||||
|
||||
Reference in new issue
Block a user