From 30662caab7cfaf3e04801515c8fb8b7f572df8c0 Mon Sep 17 00:00:00 2001 From: Meleki Date: Sun, 15 Mar 2026 09:55:44 +0100 Subject: [PATCH] =?UTF-8?q?chore:=20erledigte=20Pl=C3=A4ne=20ins=20Repo=20?= =?UTF-8?q?aufnehmen=20(Plans/=20aus=20.gitignore=20entfernt)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 - Plans/[DONE] AGENT_API_KEYS.md | 55 +++++++ Plans/[DONE] OPENAI_PROVIDER.md | 253 +++++++++++++++++++++++++++++ Plans/[DONE] SCAN_GITHUB_EVENTS.md | 215 ++++++++++++++++++++++++ Plans/[DONE] SCAN_GITHUB_ISSUES.md | 126 ++++++++++++++ Plans/[DONE] SCAN_HUGGINGFACE.md | 118 ++++++++++++++ 6 files changed, 767 insertions(+), 3 deletions(-) create mode 100644 Plans/[DONE] AGENT_API_KEYS.md create mode 100644 Plans/[DONE] OPENAI_PROVIDER.md create mode 100644 Plans/[DONE] SCAN_GITHUB_EVENTS.md create mode 100644 Plans/[DONE] SCAN_GITHUB_ISSUES.md create mode 100644 Plans/[DONE] SCAN_HUGGINGFACE.md diff --git a/.gitignore b/.gitignore index 6b2d41a..61dac5d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,3 @@ data/ Temp/ appsettings.Production.json DEVY.md - -/ExampleScannerProject/ -/Plans/ diff --git a/Plans/[DONE] AGENT_API_KEYS.md b/Plans/[DONE] AGENT_API_KEYS.md new file mode 100644 index 0000000..c3f473f --- /dev/null +++ b/Plans/[DONE] AGENT_API_KEYS.md @@ -0,0 +1,55 @@ +# Plan: API Key pro Agent + +## Übersicht +Statt einem globalen API-Key pro User wird der Key **pro Agent** zugewiesen. +Kein Key = kein Chat. Saubere Trennung. + +## Datenbank + +### Neue Tabelle `agent_api_keys` +```sql +CREATE TABLE agent_api_keys ( + user_id TEXT NOT NULL, + agent_id TEXT NOT NULL, + key_id TEXT NOT NULL, + UNIQUE(user_id, agent_id) +); +``` + +### Neue DB-Methoden +- `SetAgentApiKey(string userId, string agentId, string keyId)` +- `GetAgentApiKey(string userId, string agentId)` → key_id oder null +- `GetAgentApiKeyRecord(string userId, string agentId)` → vollständiges ApiKey-Objekt + +### Migration +- Bestehende `users.selected_api_key_id` Werte → in `agent_api_keys` für alle Agents des Users übernehmen (einmalig) +- `users.selected_api_key_id` bleibt vorerst in der Tabelle (kein DROP), wird aber nicht mehr aktiv genutzt + +## Backend (Endpoints) + +### Angepasste Endpoints +- **`PUT /api/api-keys/select/{keyId}`** → neuer Query-Parameter `?agentId=xxx` +- **`GET /api/api-keys/selected`** → neuer Query-Parameter `?agentId=xxx` + +### Chat/Services +- **`ChatEndpoint`** → `GetAgentApiKeyRecord(userId, agentId)` statt `GetUserSelectedApiKey(userId)` +- **`TelegramService`** → `GetAgentApiKeyRecord(userId, agentId)` statt `GetUserSelectedApiKey(userId)` +- **`CronjobService`** → `GetAgentApiKeyRecord(userId, agentId)` statt `GetUserSelectedApiKey(userId)` + +### Fehler-Handling +- Kein Key für Agent zugewiesen → Fehlermeldung: "Kein API Key für diesen Agent zugewiesen" +- Kein Fallback auf globalen Key + +## Frontend + +### Key-Switch-Modal +- Bekommt `agentId` als Parameter (aus aktuellem Chat/Session) +- Select-Call sendet `agentId` mit +- Zeigt aktuell zugewiesenen Key für diesen Agent + +### Usage-Badge +- Zeigt den Key des aktuellen Agents (nicht den globalen) + +### API-Calls +- `selectApiKey(keyId, agentId)` → `PUT /api/api-keys/select/{keyId}?agentId={agentId}` +- `getSelectedApiKey(agentId)` → `GET /api/api-keys/selected?agentId={agentId}` diff --git a/Plans/[DONE] OPENAI_PROVIDER.md b/Plans/[DONE] OPENAI_PROVIDER.md new file mode 100644 index 0000000..3a4f50c --- /dev/null +++ b/Plans/[DONE] OPENAI_PROVIDER.md @@ -0,0 +1,253 @@ +# Plan: OpenAI als nativer Provider + +## Übersicht + +OpenAI (GPT-4o, GPT-5, o3, etc.) als vollwertigen Provider integrieren – gleichwertig mit Anthropic. +Der Key kommt aus der `api_keys`-Tabelle (Provider: `openai`), nicht aus `appsettings.json`. + +## Ist-Zustand + +### Architektur +- **AnthropicService** – Haupt-Provider, voller Feature-Support (Tools, Review, Preparer, Finalizer, Web-Search, Memory, ask_user_choice, Plan-Mode) +- **OpenAiService** – "Neben-Provider" für Nvidia, Pollinations, Gemini. Limitiert: + - Nur 6 Tools (list_files, read_file, write_file, edit_file, delete_file, execute) + - Kein Review/Preparer/Finalizer + - Kein Memory, Web-Search, ask_user_choice + - API-Key hardcoded im `Providers`-Dictionary (nicht aus DB) + - `maxIterations` fest auf 10 + +### API-Key-System +- User wählt einen Key aus der `api_keys`-Tabelle (`selected_api_key_id`) +- Aktuell nur für Anthropic genutzt (`userApiKey.ApiKey` → `anthropic.StreamChat()`) +- OpenAi-Provider nutzen eigene Keys aus `Providers`-Dict (Gemini aus `appsettings.json`, Nvidia/Pollinations keyless) + +### Modell-Auswahl +- Agent hat `Model`-Feld, z.B. `sonnet-4-6` oder `nvidia:model-id` +- `ChatService.ResolveModelId()` mapped Anthropic-Kurzformen, OpenAI-Provider werden durchgereicht +- Frontend: `