Commit Graph

63 Commits

Author SHA1 Message Date
gitea b13a8afa01 bot: queued AI query interface + librarian AI review of results
CI / integration (push) Failing after 2m23s
CI / compile (push) Failing after 1h53m43s
CI / unit (push) Failing after 1h53m32s
build / build (push) Failing after 1h54m2s
Two connected features.

1) AI query interface (via the comm layer). communication_subroutine gains an
AI_QUERY_Q, a submit_ai_query() in-process entry point, and an authed
POST /ai_query endpoint ({prompt, channel_id, request_type?, username?}). The
prompt is queued and answered asynchronously by a new tasks.loop worker in the
always-loaded AI cog (Events), which calls handle_response - so it runs on
whichever backend $gadaj_teraz currently selects (GPT or Claude) - and posts the
answer to the requested channel, chunked to Discord's limit. request_type "NONE"
(default) is a clean one-shot: no persona system prompt, no memory write. The
worker starts before the OpenAI guard in cog_load, so it also runs on a
Claude-only box; cog_unload cancels it.

2) Librarian AI review. New command $wyszukaj_z_recenzja mirrors
$wyszukaj_linki_do_dokumentow but sets ai_review=True on the QueryControl, which
rides the round-trip and is matched back by UUID. When the hits return,
check_data_q sends the raw list as before, then - if flagged - hands the same
list (already in Crossref-relevance order) plus the search phrase to the AI
queue for a weighted re-rank and per-source review, delivered to the same
channel. QueryControl gains an ai_review flag (default False, so the orphan path
and all existing callers are unaffected).

Confirmed separately (and noted in the docs): the DOI list the AI receives is
pre-sorted by Crossref relevance - the librarian pipeline only filters (drops
title-less items) and splits (in-db / not-in-db), never re-sorts, and relies on
insertion-ordered dicts (Py 3.7+).

Verified: /ai_query auth (401/200/400/open), submit_ai_query and the queued
dict shape, and the QueryControl flag - via a Flask test client and
tests/integration/test_ai_query_endpoint.py (5 tests, all pass; integration
suite 11 passed, the 3 failures are the pre-existing /clear_pr_pls musician
tests fixed on a separate branch). Full first-party compile clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-30 09:27:11 +00:00
Michal Tuszowski f70a541b55 ai: $gadaj_teraz without an argument reports the active backend
Quality-of-life: checking which AI backend is live no longer requires
switching to it. Bare `$gadaj_teraz` replies with the active config and the
selectable ones; that read-only path is open to everyone, while switching
stays Vykidailo-gated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-18 13:45:36 +02:00
Michal Tuszowski 3d9d47aa90 ai: single-switch GPT/Claude backend for the chat cog
Wire the bot's AI chat pipeline (ai_functions.handle_response) to talk to
either OpenAI or the Anthropic Messages API, chosen by one active-config
switch. Behaviour on the default "gpt" config is unchanged.

constants.py:
* guarded `import anthropic` + CLAUDECLIENT (mirrors OPENAICLIENT), netrc
  machine 'anthropic' / ANTHROPIC_API_KEY;
* CLAUDE_LATEST_MODEL / CLAUDE_CHEAP_MODEL (opus-4-8 / haiku-4-5);
* AI_CONFIGS + DEFAULT_AI_CONFIG loaded from an optional 3rd element of
  system_gpt_settings.json (backward compatible - a 2-element file falls
  back to built-in defaults, active "gpt"). Single switch: CONJURER_AI_CONFIG
  env > settings "active" > "gpt".

ai_functions.py:
* provider_generate() dispatches to OpenAI (unchanged openai_call) or the new
  _anthropic_call() (splits system out, alternating messages, max_tokens,
  temperature omitted - Opus 4.8 rejects sampling params);
* AIError normalises both SDKs' exceptions into one category set so
  handle_response keeps its single set of in-character error replies;
* select_model() reads the active config; legacy "gpt-4o" default auto-maps
  to the active provider's model so the switch actually changes the backend;
* set_active_ai_config()/list_ai_configs() with best-effort persistence back
  into system_gpt_settings.json index 2.

ai_commands.py:
* $gadaj_teraz <config> hybrid command (Vykidailo-gated) switches backend at
  runtime;
* graceful guards when OPENAICLIENT is None: personal assistants (OpenAI
  Assistants API) and DALL-E image gen degrade instead of crashing, so a
  Claude-only deployment boots.

system_gpt_settings.json: add the configs block (gpt/claude/_template) as the
collection point for future backends. requirements_bot.txt: add anthropic.
bot.env.example: ANTHROPIC_API_KEY + CONJURER_AI_CONFIG. Unit tests cover the
message splitter, model selection, config listing, and error mapping.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-09 21:34:59 +02:00
Michal Tuszowski a64fb2da57 Restructure: promote working_copy to repo root
Make the stable 'working copy' bot the canonical code at the repository
root so the install/deploy scripts operate against it again.

- Move working_copy/* to root (bot entrypoint is bot.py)
- Restore root-level install/ops scripts from c4fa88e (deploy.sh,
  install_main_bot.sh, status_report.*, conjurer.service, etc.)
- Fix deploy.sh: copy bot.py (was thin_client.py) and add the
  conanjurer_* modules; bump command count
- Remove side-by-side variant dirs (backup_old_docker, prototype_one,
  prototype_musician_one, musician_old, working_copy) and docker cruft
- Keep components as subdirs: conjurer_librarian, conjurer_musician,
  spotify_dl, yt_dlp, fonts, utils, docs

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-28 23:50:55 +02:00
Michal Tuszowski 8e5e4ce530 Backup old. Preparation for forking 2026-06-16 14:09:27 +02:00
gitea 97f43bc6a7 Update AI and librarian commands to use 'GENERAL' context" 2025-08-16 16:58:28 +02:00
gitea cf27b2f3f9 Finally fixed this bug. The AI can now play perfectly. 2025-01-31 20:08:38 +01:00
gitea 3b7248cb00 Fixit 2025-01-21 21:47:13 +01:00
gitea e35e028001 Fixc
Fixc
2025-01-21 21:36:07 +01:00
gitea 2c19e4565e Add comment 2025-01-21 16:53:09 +01:00
gitea 853e952128 Hej hoppsan! 2025-01-21 16:51:33 +01:00
gitea 041544917c Literowka 2025-01-21 15:44:43 +00:00
gitea 3ed4dcfbb4 add exception handling 2025-01-13 20:34:26 +00:00
gitea dc8787956d finally fixed the bug 2024-12-19 22:58:38 +01:00
gitea b499a6b456 TEst 2024-12-19 22:51:46 +01:00
gitea f44994688e All thirteen 2024-12-19 22:37:16 +01:00
gitea 2da45012f3 ied 2024-12-19 22:13:30 +01:00
gitea ff9d2c67f0 Fuck whoever designed dicts in python that way 2024-12-19 21:59:58 +01:00
gitea 20ac94b61d THis commit should be theoretically the last 2024-12-19 21:55:57 +01:00
gitea 21ec8d8bc9 Some would say it's ccr. But I'm not i*n. 2024-12-19 11:54:53 +01:00
gitea aa92b7f512 FX 2024-12-19 11:08:29 +01:00
gitea 4ece2f215e 1111 2024-12-19 00:27:45 +01:00
gitea 85f91b3994 serio kurwa ja pierdole niech to kurwa bedzie ostatnia poprawka debilnego błedu w tym pierdolonym kodzie 2024-12-19 00:14:08 +01:00
gitea ca2e1a35aa kurwa serio 2024-12-19 00:10:23 +01:00
gitea f9dcec6d9e Testr 2024-12-19 00:07:04 +01:00
gitea cc57b0c52d FX 2024-12-18 23:21:21 +01:00
gitea b6bbb50707 bugfix 2024-12-01 12:00:43 +01:00
gitea 3d5d8a2c14 saving repeatable promtp 2024-11-28 11:24:22 +01:00
gitea 194674705e fx 2024-11-28 10:48:30 +01:00
gitea b513704a3d BGFX 2024-11-25 14:41:45 +01:00
gitea 69afb00897 bgfx 1 2024-11-16 23:10:32 +01:00
gitea 4f109da335 bgfx 2024-11-15 19:01:53 +01:00
gitea 230242bf5c finished secret dm handling 2024-11-15 18:47:29 +01:00
gitea e290e7d656 ADdded smth 2024-11-15 18:33:31 +01:00
gitea 62f6b64bfb Fix 2024-11-15 15:44:17 +01:00
gitea cd307d642e fix 2024-11-15 15:41:56 +01:00
gitea 81c43aadcc xxx 2024-11-15 14:01:25 +01:00
gitea 73057921ec Optional argument fix 2024-11-15 13:30:23 +01:00
gitea cd1beac93f small fx 2024-11-15 11:16:40 +01:00
gitea 784163b9c9 Enum fix 2024-11-15 11:13:41 +01:00
gitea 8429d4efd5 Start of Armia Hammera 2024-11-15 11:10:49 +01:00
gitea 06192c41ad Semi-fnal commit for today 2024-11-15 01:12:37 +01:00
gitea 22730776d4 Fix ? 2024-11-15 01:08:34 +01:00
gitea a72dba291b tst 2024-11-15 01:00:41 +01:00
gitea b98e3e4ebc Fix 2024-11-15 00:56:23 +01:00
gitea ff2669d079 fix 2024-11-15 00:53:22 +01:00
gitea 4a6afa14cc bold commiting at the end of the day 2024-11-15 00:37:14 +01:00
gitea 637926973c tst 2024-11-14 21:48:24 +01:00
gitea b15c2f06b8 Work ongoing - rich presence and ai assistant 2024-11-14 19:53:40 +01:00
gitea e05f58624a fx 2024-11-13 22:48:40 +01:00