Skip to content

Commit e272f22

Browse files
committed
feat: 添加自动检测max_tokens时显示"Detecting..."的功能
1 parent 16eaa0f commit e272f22

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

core/admin/agent_admin.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@ class OpenAIAgentAdmin(AgentAdmin):
6868
"is_valid",
6969
"masked_api_key",
7070
"model",
71-
"max_tokens",
71+
"show_max_tokens",
7272
"base_url",
7373
]
74-
readonly_fields = ["show_log", "max_tokens"]
74+
readonly_fields = ["show_log","show_max_tokens"]
7575
fieldsets = (
7676
(
7777
_("Model Information"),
@@ -96,12 +96,18 @@ class OpenAIAgentAdmin(AgentAdmin):
9696
"frequency_penalty",
9797
"presence_penalty",
9898
"rate_limit_rpm",
99-
"max_tokens",
99+
"show_max_tokens",
100100
)
101101
},
102102
),
103103
)
104104

105+
@admin.display(description=_("Max Tokens"))
106+
def show_max_tokens(self, obj):
107+
if obj.max_tokens == 0:
108+
return "Detecting..."
109+
return obj.max_tokens
110+
105111

106112
class DeepLAgentAdmin(AgentAdmin):
107113
fields = ["name", "api_key", "server_url", "proxy", "max_characters", "show_log"]

0 commit comments

Comments
 (0)