УЛЬТРА КРУТОЙ ВАЙБКОД ФИКСЫ И АВТОМОДЕЛЬ ТЕСЛА
This commit is contained in:
1 parent
5be8fcce19
commit
b0541faa3d
8 files changed
+328
-106
No files matched your search
+48
-17
@@ -24,32 +24,39 @@ async def select_provider_callback(callback: CallbackQuery):
|
||||
|
||||
config = get_user_config(user_id)
|
||||
user_model = config.get("model")
|
||||
|
||||
|
||||
buttons = []
|
||||
|
||||
i = 0
|
||||
shown = set()
|
||||
|
||||
for model in MODELS.get(provider):
|
||||
base_model = model.split("*")[0] if "*" in model else model
|
||||
if base_model in shown:
|
||||
continue
|
||||
shown.add(base_model)
|
||||
|
||||
i += 1
|
||||
if f"{provider}*{model}" == user_model:
|
||||
text = f"{model} ✅"
|
||||
full_model = f"{provider}*{base_model}"
|
||||
if full_model == user_model or user_model.startswith(full_model + "*"):
|
||||
text = f"{base_model} ✅"
|
||||
else:
|
||||
text = model
|
||||
|
||||
text = base_model
|
||||
|
||||
if MODELS[provider][model].get("alias"):
|
||||
model = MODELS[provider][model].get("alias")
|
||||
base_model = MODELS[provider][model].get("alias")
|
||||
|
||||
if not i % 2:
|
||||
buttons[len(buttons)-1] +=[
|
||||
InlineKeyboardButton(
|
||||
text=text, callback_data=f"set_model%{user_id}%{provider}*{model}"
|
||||
text=text, callback_data=f"set_model%{user_id}%{provider}*{base_model}"
|
||||
)
|
||||
]
|
||||
else:
|
||||
buttons.append(
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=text, callback_data=f"set_model%{user_id}%{provider}*{model}"
|
||||
text=text, callback_data=f"set_model%{user_id}%{provider}*{base_model}"
|
||||
)
|
||||
]
|
||||
)
|
||||
@@ -75,9 +82,12 @@ async def select_provider_callback(callback: CallbackQuery):
|
||||
|
||||
|
||||
@router.callback_query(F.data.startswith("models%"))
|
||||
async def models_callback(callback: CallbackQuery):
|
||||
async def models_callback(callback: CallbackQuery, alo=""):
|
||||
current_user_id = str(callback.from_user.id)
|
||||
data = callback.data.split("%", 1)
|
||||
if alo:
|
||||
data = alo.split("%", 1)
|
||||
else:
|
||||
data = callback.data.split("%", 1)
|
||||
user_id = data[1]
|
||||
if user_id == current_user_id:
|
||||
config = get_user_config(user_id)
|
||||
@@ -85,6 +95,16 @@ async def models_callback(callback: CallbackQuery):
|
||||
buttons = []
|
||||
|
||||
i = 0
|
||||
|
||||
if AUTO_MODEL and AUTO_MODELS:
|
||||
if config["model"] == "all*auto":
|
||||
buttons.append(
|
||||
[InlineKeyboardButton(text="✅ автовыбор", callback_data=f"set_model%{user_id}%{DEFAULT_MODEL}")]
|
||||
)
|
||||
else:
|
||||
buttons.append(
|
||||
[InlineKeyboardButton(text="😱 автовыбор", callback_data=f"set_model%{user_id}%all*auto")]
|
||||
)
|
||||
|
||||
for provider in MODELS:
|
||||
i += 1
|
||||
@@ -134,12 +154,16 @@ async def set_model_callback(callback: CallbackQuery):
|
||||
user_id, new_model = data[1], data[2]
|
||||
provider = data[2].split("*", 1)[0]
|
||||
amodel = data[2].split("*", 1)[1]
|
||||
new_model = provider + "*" + amodel
|
||||
|
||||
for model in MODELS.get(provider):
|
||||
nmodel = MODELS[provider][model].get("alias") or None
|
||||
if nmodel == amodel:
|
||||
new_model = provider + "*" + model
|
||||
|
||||
if amodel == "auto" and provider == "all":
|
||||
new_model = "all*auto"
|
||||
else:
|
||||
new_model = provider + "*" + amodel
|
||||
for model in MODELS.get(provider, {}):
|
||||
nmodel = MODELS[provider][model].get("alias") or None
|
||||
if nmodel == amodel:
|
||||
new_model = provider + "*" + model
|
||||
break
|
||||
|
||||
if user_id == current_user_id:
|
||||
current_config = get_user_config(user_id)
|
||||
@@ -153,7 +177,14 @@ async def set_model_callback(callback: CallbackQuery):
|
||||
current_config.get("markdown"),
|
||||
current_config.get("prompts")
|
||||
)
|
||||
await callback.message.edit_text(f"выбрана модель: `{new_model}`")
|
||||
await callback.message.edit_text(
|
||||
f"выбрана модель: `{new_model}`",
|
||||
reply_markup=InlineKeyboardMarkup(inline_keyboard=
|
||||
[
|
||||
[InlineKeyboardButton(text="⬅️ назад", callback_data=f"models%{user_id}")]
|
||||
]
|
||||
)
|
||||
)
|
||||
await callback.answer(f"выбрано: {new_model}")
|
||||
else:
|
||||
await callback.answer("нет, не трогай")
|
||||
|
||||
Reference in new issue
Block a user