удалить траст
This commit is contained in:
1 parent
351ef31489
commit
5d76e154e0
4 files changed
+2
-71
No files matched your search
+2
-11
@@ -10,7 +10,6 @@ from aiogram.types import (
|
||||
from commands import *
|
||||
from config import *
|
||||
from supergenerator import *
|
||||
from trust import *
|
||||
|
||||
|
||||
@router.callback_query(F.data.startswith("prov%"))
|
||||
@@ -31,8 +30,6 @@ async def select_provider_callback(callback: CallbackQuery):
|
||||
i = 0
|
||||
shown = set()
|
||||
|
||||
auto_entries = expand_auto_models()
|
||||
|
||||
for model in MODELS.get(provider):
|
||||
base_model = model.split("*")[0] if "*" in model else model
|
||||
if base_model in shown:
|
||||
@@ -41,16 +38,10 @@ async def select_provider_callback(callback: CallbackQuery):
|
||||
|
||||
i += 1
|
||||
full_model = f"{provider}*{base_model}"
|
||||
in_auto = any(e == full_model or e.startswith(full_model + "*") for e in auto_entries)
|
||||
if in_auto:
|
||||
m_trust = round(get_display_trust([provider, base_model]))
|
||||
model_text = f"{base_model} ({m_trust}%)"
|
||||
else:
|
||||
model_text = base_model
|
||||
if full_model == user_model or user_model.startswith(full_model + "*"):
|
||||
text = f"{model_text} ✅"
|
||||
text = f"{base_model} ✅"
|
||||
else:
|
||||
text = model_text
|
||||
text = base_model
|
||||
|
||||
if MODELS[provider][model].get("alias"):
|
||||
base_model = MODELS[provider][model].get("alias")
|
||||
|
||||
@@ -5,7 +5,6 @@ from colors import *
|
||||
from helpers import *
|
||||
from config import *
|
||||
from vars import *
|
||||
from trust import *
|
||||
|
||||
from aiogram.exceptions import TelegramBadRequest
|
||||
|
||||
@@ -130,13 +129,6 @@ async def generate(
|
||||
await msg.edit_text(make_graph(message, process))
|
||||
|
||||
expanded = expand_auto_models()
|
||||
expanded = [
|
||||
e for _, e in sorted(
|
||||
enumerate(expanded),
|
||||
key=lambda x: get_trust(x[1].split("*"))[1] + (5 if x[0] == 0 else 0),
|
||||
reverse=True
|
||||
)
|
||||
]
|
||||
last_type = ""
|
||||
for entry in expanded:
|
||||
if last_type == "da":
|
||||
@@ -171,9 +163,7 @@ async def generate(
|
||||
message_id=message_id,
|
||||
inline_id=inline_id
|
||||
)
|
||||
update_trust(parts, text)
|
||||
last_type = text["type"]
|
||||
|
||||
if text == "":
|
||||
text = {"type": "error", "text": "все модели в автовыборе вернули ошибку"}
|
||||
else:
|
||||
@@ -214,7 +204,6 @@ async def generate(
|
||||
message_id=message_id,
|
||||
inline_id=inline_id
|
||||
)
|
||||
update_trust(model, text)
|
||||
|
||||
if user_id:
|
||||
user_contexts[user_id].append({"role": "assistant", "content": {"type": "text", "text": text["text"]}})
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
from vars import models_trust
|
||||
|
||||
|
||||
def trust_key(m: list):
|
||||
if len(m) >= 3:
|
||||
return m[0] + '*' + m[1] + '*' + m[2]
|
||||
return m[0] + '*' + m[1]
|
||||
|
||||
|
||||
def update_trust(m: list, text: dict):
|
||||
provider_key = m[0]
|
||||
model_key = trust_key(m)
|
||||
if provider_key not in models_trust:
|
||||
set_trust(provider_key, 80.0)
|
||||
if model_key not in models_trust:
|
||||
set_trust(model_key, 60.0)
|
||||
if text['type'] == 'error':
|
||||
if models_trust[model_key] > 10:
|
||||
models_trust[model_key] += -0.5
|
||||
models_trust[provider_key] += -0.08
|
||||
elif text['type'] == 'net':
|
||||
if models_trust[model_key] > 10:
|
||||
models_trust[model_key] += -0.2
|
||||
models_trust[provider_key] += -0.05
|
||||
elif text['type'] == 'da':
|
||||
if models_trust[model_key] < 100:
|
||||
models_trust[model_key] += 2
|
||||
models_trust[provider_key] += 0.2
|
||||
|
||||
|
||||
def get_trust(m: list):
|
||||
return models_trust.get(m[0], 80.0), models_trust.get(trust_key(m), 60.0)
|
||||
|
||||
|
||||
def get_display_trust(m: list):
|
||||
base_key = m[0] + '*' + m[1]
|
||||
values = []
|
||||
for key, val in models_trust.items():
|
||||
if key == base_key or key.startswith(base_key + '*'):
|
||||
values.append(val)
|
||||
if not values:
|
||||
return 60.0
|
||||
return sum(values) / len(values)
|
||||
|
||||
|
||||
def set_trust(m: str, trust: float):
|
||||
models_trust[m] = trust
|
||||
Reference in new issue
Block a user