recovered snapshot from suspended aaronjaworski710 (history unavailable)

This commit is contained in:
reform
2026-10-23 20:03:57 +03:00
commit e91e29d95d
14 changed files with 961 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
"""Пример: супервизор кодинг-агента (паттерн thruwire/foreman).
После каждого шага агента Jev решает: continue / retry / verify / stop."""
import sys, os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from jev_client import decide
CRITERIA = {
'continue': 'Шаг успешен, план выполняется — давай агенту следующий шаг',
'retry': 'Шаг упал по исправимой причине (таймаут, синтаксис, flaky-тест) — повтори с корректировкой',
'verify': 'Результат неоднозначен — сначала проверь (тесты/линтер/запуск), потом решай',
'stop': 'Агент зациклился, исчерпал бюджет или задача не сходится — останови и эскалируй человеку',
}
def supervise(goal: str, step_log: str, attempt: int) -> dict:
r = decide(state=f"Agent goal: {goal}\nAttempt #{attempt}\nLatest step log:\n{step_log[-4000:]}",
questions={
'next': {'type': 'choice', 'instructions': 'What should the supervising layer do next?',
'criteria': CRITERIA},
'stuck': {'type': 'noul', 'instructions': 'Is the agent stuck in a loop (repeating same failing action)?'},
'progress': {'type': 'score', 'instructions': 'Rate overall progress toward the goal',
'criteria': ['no progress', 'minor', 'halfway', 'mostly done', 'done']},
})
a = r['answers']
return {'next': a['next']['choice'], 'stuck': a['stuck']['noul'] > 0.5,
'progress': a['progress']['score'], 'confidence': a['next'].get('confidence')}
if __name__ == '__main__':
log = 'ran pytest: 3 failed, 12 passed. Failure: AssertionError in test_parse_config (same as attempt 1 and 2)'
print(supervise('починить парсер конфига', log, attempt=3))
+30
View File
@@ -0,0 +1,30 @@
"""Пример: роутер задач на модели через Jev.
Дешёвая/умная/визуальная модель выбирается одним вызовом вместо прогона через LLM."""
import sys, os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from jev_client import decide
CRITERIA = {
'cheap': 'Простые запросы: перевод коротких текстов, классификация, извлечение, шаблоны, chitchat',
'smart': 'Сложные запросы: рассуждения, математика, код-ревью, планирование, многошаговые задачи',
'vision': 'Запрос содержит изображения, скриншоты, PDF со схемами, или требует визуального понимания',
}
def route(task: str) -> dict:
r = decide(state=f"User task: {task}", questions={
'model': {'type': 'choice', 'instructions': 'Which model tier should handle this task?',
'criteria': CRITERIA},
'needs_tools': {'type': 'noul', 'instructions': 'Does this task require tool/web access?'},
})
a = r['answers']
return {'model': a['model']['choice'],
'confidence': a['model'].get('confidence'),
'needs_tools': a['needs_tools']['noul'] > 0.5}
if __name__ == '__main__':
for t in ['переведи hello world на русский',
'найди баг в этом async коде и объясни race condition',
'что на этом скриншоте ошибки? [image attached]']:
res = route(t)
print(f"{res['model']:7} conf={res['confidence']:.2f} tools={res['needs_tools']} | {t[:50]}")
+32
View File
@@ -0,0 +1,32 @@
"""Пример: спам-модерация постов/сообщений через Jev.
Порог по noul + действие через choice. Один вызов на пост, ~1 кредит."""
import sys, os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from jev_client import decide
SPAM_THRESHOLD = 0.7
def moderate(post_text: str, author_meta: str = '') -> dict:
state = f"Post: {post_text}\nAuthor: {author_meta or 'unknown'}"
r = decide(state=state, questions={
'spam': {'type': 'noul', 'instructions': 'Is this post spam/scam/ads for grey services?'},
'nsfw': {'type': 'noul', 'instructions': 'Does this contain NSFW content?'},
'action': {'type': 'choice', 'instructions': 'Choose moderation action',
'criteria': {'ban': 'ban author and delete', 'delete': 'delete post only',
'flag': 'flag for human review', 'keep': 'leave as is'}},
})
a = r['answers']
verdict = 'BLOCK' if a['spam']['noul'] >= SPAM_THRESHOLD or a['nsfw']['noul'] >= SPAM_THRESHOLD else 'PASS'
return {'verdict': verdict, 'spam': a['spam']['noul'], 'nsfw': a['nsfw']['noul'],
'action': a['action']['choice'], 'confidence': a['action'].get('confidence')}
if __name__ == '__main__':
samples = [
'Продаю аккаунты Telegram с историей, дешево, писать в лс @spamlord',
'Кто-нибудь пробовал jev-ai.pro? Как вам качество решений по сравнению с GPT?',
'СКАЧАЙ КРЯК БЕЗ СМС >>> http://bit.ly/fr3e-win',
]
for s in samples:
res = moderate(s)
print(f"{res['verdict']:5} spam={res['spam']:.2f} action={res['action']:7} | {s[:60]}")
+29
View File
@@ -0,0 +1,29 @@
"""Пример: трейдинг-сигнал buy/sell/wait с confidence-гейтом.
НЕ финансовый совет — демонстрация паттерна (см. jarrodwatts/jev-trader)."""
import sys, os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from jev_client import decide
MIN_CONFIDENCE = 0.6 # ниже порога -> всегда wait
def signal(snapshot: dict) -> dict:
"""snapshot: {'pair':'BTC/USDT','price':...,'change_24h':...,'rsi':...,'news':'...'}"""
r = decide(state=f"Market snapshot: {snapshot}", questions={
'action': {'type': 'choice', 'instructions': 'Decide the next trade action for a short-term position',
'criteria': {'buy': 'momentum and sentiment favour entry now',
'sell': 'take profit / cut risk now',
'wait': 'not enough edge, stay flat'}},
'risk': {'type': 'score', 'instructions': 'How risky is entering right now?',
'criteria': ['low', 'medium', 'high', 'extreme']},
'volatile': {'type': 'noul', 'instructions': 'Is the market unusually volatile per this snapshot?'},
})
a = r['answers']
act = a['action']['choice'] if a['action'].get('confidence', 0) >= MIN_CONFIDENCE else 'wait'
return {'action': act, 'confidence': a['action'].get('confidence'),
'risk': a['risk']['score'], 'volatile': a['volatile']['noul']}
if __name__ == '__main__':
snap = {'pair': 'BTC/USDT', 'price': 118420, 'change_24h': '-3.8%', 'rsi': 31,
'news': 'ETF outflows 2nd day, macro risk-off, no major liquidation cascade yet'}
print(signal(snap))