AI Update: خب روی نشانگر زنده تفکر اسم پروژه رو ننویس و به جاش بگو در ح
This commit is contained in:
+19
-11
@@ -45,6 +45,7 @@ from formatters import (
|
|||||||
format_thought,
|
format_thought,
|
||||||
format_tool_call,
|
format_tool_call,
|
||||||
format_context_stats,
|
format_context_stats,
|
||||||
|
get_model_display_name,
|
||||||
format_git_info,
|
format_git_info,
|
||||||
format_git_commits_page,
|
format_git_commits_page,
|
||||||
format_commit_detail_view,
|
format_commit_detail_view,
|
||||||
@@ -2744,12 +2745,15 @@ async def process_agent_turn_by_chat_id(
|
|||||||
if initial_status_text:
|
if initial_status_text:
|
||||||
initial_status = initial_status_text
|
initial_status = initial_status_text
|
||||||
else:
|
else:
|
||||||
|
model_to_use = getattr(curr_proj, "model", None) or getattr(session, "model", None) or settings.default_model or "gemini-3.7-flash-auto"
|
||||||
|
effort_to_use = getattr(curr_proj, "reasoning_effort", None) or getattr(session, "reasoning_effort", None)
|
||||||
|
model_display = get_model_display_name(model_to_use, effort_to_use)
|
||||||
initial_status = (
|
initial_status = (
|
||||||
f"📁 <b>پروژه:</b> <code>{escape_html(curr_proj.name)}</code>\n\n"
|
f"📁 <b>پروژه:</b> <code>{escape_html(curr_proj.name)}</code>\n\n"
|
||||||
f"💭 <i>در حال تفکر روی پروژه <b>{escape_html(curr_proj.name)}</b>...</i>"
|
f"💭 <i>در حال تفکر با مدل <b>{escape_html(model_display)}</b>...</i>"
|
||||||
if is_fa else
|
if is_fa else
|
||||||
f"📁 <b>Project:</b> <code>{escape_html(curr_proj.name)}</code>\n\n"
|
f"📁 <b>Project:</b> <code>{escape_html(curr_proj.name)}</code>\n\n"
|
||||||
f"💭 <i>Thinking on project <b>{escape_html(curr_proj.name)}</b>...</i>"
|
f"💭 <i>Thinking with model <b>{escape_html(model_display)}</b>...</i>"
|
||||||
)
|
)
|
||||||
status_msg = await app.bot.send_message(
|
status_msg = await app.bot.send_message(
|
||||||
chat_id=chat_id,
|
chat_id=chat_id,
|
||||||
@@ -6450,19 +6454,23 @@ async def process_agent_turn(
|
|||||||
|
|
||||||
session_manager.cancel_active_task(chat_id)
|
session_manager.cancel_active_task(chat_id)
|
||||||
|
|
||||||
# Initial thinking status message clearly stating which project is active
|
model_to_use = getattr(curr_proj, "model", None) or getattr(session, "model", None) or settings.default_model or "gemini-3.7-flash-auto"
|
||||||
|
effort_to_use = getattr(curr_proj, "reasoning_effort", None) or getattr(session, "reasoning_effort", None)
|
||||||
|
model_display = get_model_display_name(model_to_use, effort_to_use)
|
||||||
|
|
||||||
|
# Initial thinking status message clearly stating which project and model are active
|
||||||
if status_msg_to_reuse:
|
if status_msg_to_reuse:
|
||||||
status_msg = status_msg_to_reuse
|
status_msg = status_msg_to_reuse
|
||||||
else:
|
else:
|
||||||
if is_fa:
|
if is_fa:
|
||||||
initial_status = (
|
initial_status = (
|
||||||
f"📁 <b>پروژه:</b> <code>{escape_html(curr_proj.name)}</code>\n\n"
|
f"📁 <b>پروژه:</b> <code>{escape_html(curr_proj.name)}</code>\n\n"
|
||||||
f"💭 <i>در حال تفکر روی پروژه <b>{escape_html(curr_proj.name)}</b>...</i>"
|
f"💭 <i>در حال تفکر با مدل <b>{escape_html(model_display)}</b>...</i>"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
initial_status = (
|
initial_status = (
|
||||||
f"📁 <b>Project:</b> <code>{escape_html(curr_proj.name)}</code>\n\n"
|
f"📁 <b>Project:</b> <code>{escape_html(curr_proj.name)}</code>\n\n"
|
||||||
f"💭 <i>Thinking on project <b>{escape_html(curr_proj.name)}</b>...</i>"
|
f"💭 <i>Thinking with model <b>{escape_html(model_display)}</b>...</i>"
|
||||||
)
|
)
|
||||||
|
|
||||||
status_msg = await update.effective_message.reply_html(
|
status_msg = await update.effective_message.reply_html(
|
||||||
@@ -6508,21 +6516,21 @@ async def process_agent_turn(
|
|||||||
# Suffix at the BOTTOM of the message
|
# Suffix at the BOTTOM of the message
|
||||||
bottom_parts = []
|
bottom_parts = []
|
||||||
|
|
||||||
# 1. Thinking blockquote at the bottom with project name
|
# 1. Thinking blockquote at the bottom with model name
|
||||||
if settings.enable_thinking_display and thoughts:
|
if settings.enable_thinking_display and thoughts:
|
||||||
thought_content = "\n".join(thoughts[-3:])
|
thought_content = "\n".join(thoughts[-3:])
|
||||||
bottom_parts.append(format_thought(thought_content, project_name=curr_proj.name, lang=session.language).strip())
|
bottom_parts.append(format_thought(thought_content, model_name=model_display, lang=session.language).strip())
|
||||||
|
|
||||||
# 2. Active tools at the bottom
|
# 2. Active tools at the bottom
|
||||||
if settings.enable_tool_notifications and tools:
|
if settings.enable_tool_notifications and tools:
|
||||||
bottom_parts.append("\n".join(tools[-2:]).strip())
|
bottom_parts.append("\n".join(tools[-2:]).strip())
|
||||||
|
|
||||||
# 3. Status indicator at the bottom stating which project is being thought on
|
# 3. Status indicator at the bottom stating which model is being used
|
||||||
if not final:
|
if not final:
|
||||||
if is_fa:
|
if is_fa:
|
||||||
bottom_parts.append(f"💭 <i>در حال تفکر روی پروژه <b>{escape_html(curr_proj.name)}</b>...</i> ▌")
|
bottom_parts.append(f"💭 <i>در حال تفکر با مدل <b>{escape_html(model_display)}</b>...</i> ▌")
|
||||||
else:
|
else:
|
||||||
bottom_parts.append(f"💭 <i>Thinking on project <b>{escape_html(curr_proj.name)}</b>...</i> ▌")
|
bottom_parts.append(f"💭 <i>Thinking with model <b>{escape_html(model_display)}</b>...</i> ▌")
|
||||||
|
|
||||||
if raw_text.strip():
|
if raw_text.strip():
|
||||||
formatted_body = markdown_to_telegram_html(raw_text)
|
formatted_body = markdown_to_telegram_html(raw_text)
|
||||||
@@ -6536,7 +6544,7 @@ async def process_agent_turn(
|
|||||||
if bottom_parts:
|
if bottom_parts:
|
||||||
full_html = proj_header + "\n\n" + "\n\n".join(bottom_parts)
|
full_html = proj_header + "\n\n" + "\n\n".join(bottom_parts)
|
||||||
else:
|
else:
|
||||||
thinking_msg = f"💭 <i>در حال تفکر روی پروژه <b>{escape_html(curr_proj.name)}</b>...</i> ▌" if is_fa else f"💭 <i>Thinking on project <b>{escape_html(curr_proj.name)}</b>...</i> ▌"
|
thinking_msg = f"💭 <i>در حال تفکر با مدل <b>{escape_html(model_display)}</b>...</i> ▌" if is_fa else f"💭 <i>Thinking with model <b>{escape_html(model_display)}</b>...</i> ▌"
|
||||||
full_html = proj_header + "\n\n" + thinking_msg
|
full_html = proj_header + "\n\n" + thinking_msg
|
||||||
|
|
||||||
if len(full_html) > settings.max_message_length:
|
if len(full_html) > settings.max_message_length:
|
||||||
|
|||||||
@@ -33,6 +33,40 @@ def format_duration_compact(seconds: float) -> str:
|
|||||||
return f"{m}:{s:02d}"
|
return f"{m}:{s:02d}"
|
||||||
|
|
||||||
|
|
||||||
|
def get_model_display_name(model: Optional[str] = None, effort: Optional[str] = None) -> str:
|
||||||
|
"""Returns a clean user-friendly display name for the model and reasoning effort."""
|
||||||
|
if not model:
|
||||||
|
return "Gemini 3.7 Flash Auto"
|
||||||
|
|
||||||
|
m_clean = model.lower().strip()
|
||||||
|
eff_clean = (effort or "").lower().strip()
|
||||||
|
|
||||||
|
if "flash-auto" in m_clean or m_clean == "gemini-3.7-flash-auto":
|
||||||
|
if eff_clean == "high":
|
||||||
|
return "Gemini 3.7 Flash Auto [High]"
|
||||||
|
elif eff_clean == "medium":
|
||||||
|
return "Gemini 3.7 Flash Auto [Med]"
|
||||||
|
elif eff_clean == "low":
|
||||||
|
return "Gemini 3.7 Flash Auto [Low]"
|
||||||
|
return "Gemini 3.7 Flash Auto"
|
||||||
|
elif "flash-high" in m_clean:
|
||||||
|
return "Gemini 3.7 Flash [High]"
|
||||||
|
elif "3.7-flash" in m_clean:
|
||||||
|
return f"Gemini 3.7 Flash [{eff_clean.capitalize()}]" if eff_clean else "Gemini 3.7 Flash"
|
||||||
|
elif "3.6-flash" in m_clean:
|
||||||
|
return f"Gemini 3.6 Flash [{eff_clean.capitalize()}]" if eff_clean else "Gemini 3.6 Flash"
|
||||||
|
elif "3.1-pro" in m_clean or "pro" in m_clean:
|
||||||
|
return f"Gemini 3.1 Pro [{eff_clean.capitalize()}]" if eff_clean else "Gemini 3.1 Pro"
|
||||||
|
elif "opus" in m_clean:
|
||||||
|
return "Claude Opus 4.6 Thinking"
|
||||||
|
elif "sonnet" in m_clean or "claude" in m_clean:
|
||||||
|
return "Claude Sonnet 4.6 Thinking"
|
||||||
|
elif "gpt" in m_clean:
|
||||||
|
return "GPT-120B"
|
||||||
|
else:
|
||||||
|
return model
|
||||||
|
|
||||||
|
|
||||||
def format_context_stats(
|
def format_context_stats(
|
||||||
usage: Optional[Dict[str, Any]] = None,
|
usage: Optional[Dict[str, Any]] = None,
|
||||||
duration: float = 0.0,
|
duration: float = 0.0,
|
||||||
@@ -115,16 +149,22 @@ def format_context_stats(
|
|||||||
def format_thought(
|
def format_thought(
|
||||||
thought_text: str,
|
thought_text: str,
|
||||||
project_name: Optional[str] = None,
|
project_name: Optional[str] = None,
|
||||||
|
model_name: Optional[str] = None,
|
||||||
lang: str = "fa",
|
lang: str = "fa",
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Formats model reasoning / thinking process with project context."""
|
"""Formats model reasoning / thinking process with model context."""
|
||||||
if not thought_text.strip():
|
if not thought_text.strip():
|
||||||
return ""
|
return ""
|
||||||
escaped = escape_html(thought_text.strip())
|
escaped = escape_html(thought_text.strip())
|
||||||
is_fa = (lang or "").lower() in ("fa", "farsi", "persian", "🇮🇷 persian / farsi (فارسی)")
|
is_fa = (lang or "").lower() in ("fa", "farsi", "persian", "🇮🇷 persian / farsi (فارسی)")
|
||||||
if project_name:
|
|
||||||
proj_badge = escape_html(project_name)
|
label = model_name or project_name
|
||||||
header = f"💭 <b>تفکر و استدلال (پروژه: {proj_badge}):</b>" if is_fa else f"💭 <b>Reasoning / Thinking (Project: {proj_badge}):</b>"
|
if label:
|
||||||
|
badge = escape_html(label)
|
||||||
|
if model_name:
|
||||||
|
header = f"💭 <b>تفکر و استدلال (مدل: {badge}):</b>" if is_fa else f"💭 <b>Reasoning / Thinking (Model: {badge}):</b>"
|
||||||
|
else:
|
||||||
|
header = f"💭 <b>تفکر و استدلال ({badge}):</b>" if is_fa else f"💭 <b>Reasoning / Thinking ({badge}):</b>"
|
||||||
else:
|
else:
|
||||||
header = "💭 <b>تفکر و استدلال:</b>" if is_fa else "💭 <b>Reasoning / Thinking:</b>"
|
header = "💭 <b>تفکر و استدلال:</b>" if is_fa else "💭 <b>Reasoning / Thinking:</b>"
|
||||||
return f"<blockquote expandable>{header}\n{escaped}</blockquote>\n"
|
return f"<blockquote expandable>{header}\n{escaped}</blockquote>\n"
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user