Skip to content

Commit

Permalink
Merge branch 'feat/model-runtime' into deploy/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
takatost committed Jan 2, 2024
2 parents 53837db + 71cb2e0 commit 9c6950f
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion api/core/agent/agent/calc_token_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_message_rest_tokens(self, model_config: ModelConfigEntity, messages: Lis
if (parameter_rule.name == 'max_tokens'
or (parameter_rule.use_template and parameter_rule.use_template == 'max_tokens')):
max_tokens = (model_config.parameters.get(parameter_rule.name)
or model_config.parameters.get(parameter_rule.use_template))
or model_config.parameters.get(parameter_rule.use_template)) or 0

if model_context_tokens is None:
return 0
Expand Down
2 changes: 1 addition & 1 deletion api/core/agent/agent/openai_function_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def should_use_agent(self, query: str):
if (parameter_rule.name == 'max_tokens'
or (parameter_rule.use_template and parameter_rule.use_template == 'max_tokens')):
original_max_tokens = (self.model_config.parameters.get(parameter_rule.name)
or self.model_config.parameters.get(parameter_rule.use_template))
or self.model_config.parameters.get(parameter_rule.use_template)) or 0

self.model_config.parameters['max_tokens'] = 40

Expand Down
4 changes: 2 additions & 2 deletions api/core/app_runner/app_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def get_pre_calculate_rest_tokens(self, app_record: App,
if (parameter_rule.name == 'max_tokens'
or (parameter_rule.use_template and parameter_rule.use_template == 'max_tokens')):
max_tokens = (model_config.parameters.get(parameter_rule.name)
or model_config.parameters.get(parameter_rule.use_template))
or model_config.parameters.get(parameter_rule.use_template)) or 0

if model_context_tokens is None:
return -1
Expand Down Expand Up @@ -85,7 +85,7 @@ def recale_llm_max_tokens(self, model_config: ModelConfigEntity,
if (parameter_rule.name == 'max_tokens'
or (parameter_rule.use_template and parameter_rule.use_template == 'max_tokens')):
max_tokens = (model_config.parameters.get(parameter_rule.name)
or model_config.parameters.get(parameter_rule.use_template))
or model_config.parameters.get(parameter_rule.use_template)) or 0

if model_context_tokens is None:
return -1
Expand Down
2 changes: 1 addition & 1 deletion api/core/prompt/prompt_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def _calculate_rest_token(self, prompt_messages: list[PromptMessage], model_conf
if (parameter_rule.name == 'max_tokens'
or (parameter_rule.use_template and parameter_rule.use_template == 'max_tokens')):
max_tokens = (model_config.parameters.get(parameter_rule.name)
or model_config.parameters.get(parameter_rule.use_template))
or model_config.parameters.get(parameter_rule.use_template)) or 0

rest_tokens = model_context_tokens - max_tokens - curr_message_tokens
rest_tokens = max(rest_tokens, 0)
Expand Down
2 changes: 1 addition & 1 deletion api/services/app_model_config_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def validate_configuration(cls, tenant_id: str, account: Account, config: dict,

# model.mode
if model_mode:
config['model']["mode"] = model_mode
config['model']["mode"] = model_mode.value
else:
config['model']["mode"] = "completion"

Expand Down

0 comments on commit 9c6950f

Please sign in to comment.