added temperature and token count to ai config
This commit is contained in:
@@ -13,7 +13,7 @@ class QwenAi(AiBase):
|
||||
def __init__(self, model_id_or_path=default_model_id):
|
||||
super().__init__(model_id_or_path)
|
||||
|
||||
def generate(self, messages):
|
||||
def generate(self, messages, token_count=100, **kwargs):
|
||||
try:
|
||||
# prepare
|
||||
messages = [m for m in messages if m['role'] != 'system']
|
||||
@@ -22,7 +22,7 @@ class QwenAi(AiBase):
|
||||
# generate
|
||||
text = self.tokenizer.apply_chat_template(input_messages, tokenize=False, add_generation_prompt=True)
|
||||
model_inputs = self.tokenizer([text], return_tensors='pt').to(self.default_device)
|
||||
generated_ids = self.model.generate(model_inputs.input_ids, max_new_tokens=300)
|
||||
generated_ids = self.model.generate(model_inputs.input_ids, max_new_tokens=token_count)
|
||||
generated_ids = [
|
||||
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user