eq-chatbot-core 4.2.1__tar.gz → 4.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/CHANGELOG.md +12 -0
  2. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/PKG-INFO +3 -3
  3. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/README.md +2 -2
  4. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/RELEASE_NOTES.md +12 -0
  5. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/providers/anthropic_provider.py +11 -0
  6. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/providers/anthropic_shared.py +12 -0
  7. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/providers/base.py +22 -4
  8. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/providers/langdock_provider.py +137 -21
  9. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/providers/openai_compatible.py +4 -0
  10. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/version.py +1 -1
  11. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/.gitignore +0 -0
  12. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/LICENSE +0 -0
  13. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/pyproject.toml +0 -0
  14. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/__init__.py +0 -0
  15. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/cli.py +0 -0
  16. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/data/__init__.py +0 -0
  17. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/data/config.toml.example +0 -0
  18. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/mcp/__init__.py +0 -0
  19. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/mcp/client.py +0 -0
  20. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/mcp/streamable_http.py +0 -0
  21. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/providers/__init__.py +0 -0
  22. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/providers/ionos_provider.py +0 -0
  23. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/providers/litellm_provider.py +0 -0
  24. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/providers/local_provider.py +0 -0
  25. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/providers/mammouth_provider.py +0 -0
  26. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/providers/melious_provider.py +0 -0
  27. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/providers/openai_provider.py +0 -0
  28. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/providers/openrouter_provider.py +0 -0
  29. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/providers/param_learning.py +0 -0
  30. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/providers/privatemode_provider.py +0 -0
  31. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/providers/stream_accumulator.py +0 -0
  32. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/providers/temperature_constraints.py +0 -0
  33. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/py.typed +0 -0
  34. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/rag/__init__.py +0 -0
  35. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/rag/chunker.py +0 -0
  36. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/rag/context_manager.py +0 -0
  37. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/rag/embedder.py +0 -0
  38. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/rag/retriever.py +0 -0
  39. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/realtime/__init__.py +0 -0
  40. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/realtime/abc.py +0 -0
  41. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/realtime/contracts.py +0 -0
  42. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/realtime/factory.py +0 -0
  43. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/realtime/mock.py +0 -0
  44. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/realtime/providers/__init__.py +0 -0
  45. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/realtime/providers/elevenlabs.py +0 -0
  46. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/realtime/providers/gemini_live.py +0 -0
  47. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/realtime/providers/openai.py +0 -0
  48. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/realtime/websocket_client.py +0 -0
  49. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/security/__init__.py +0 -0
  50. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/security/encryption.py +0 -0
  51. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/security/file_validator.py +0 -0
  52. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/security/injection.py +0 -0
  53. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/security/rate_limit.py +0 -0
  54. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/server/__init__.py +0 -0
  55. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/server/app.py +0 -0
  56. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/server/auth.py +0 -0
  57. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/server/lifecycle.py +0 -0
  58. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/server/models.py +0 -0
  59. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/server/streaming.py +0 -0
  60. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/services/__init__.py +0 -0
  61. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/services/capability_catalog.py +0 -0
  62. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/services/document_extractor.py +0 -0
  63. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/services/error_handler.py +0 -0
  64. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/services/knowledge_service.py +0 -0
  65. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/utils/__init__.py +0 -0
  66. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/utils/config.py +0 -0
  67. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/utils/image.py +0 -0
  68. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/utils/pdf.py +0 -0
  69. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/utils/secret_scrub.py +0 -0
  70. {eq_chatbot_core-4.2.1 → eq_chatbot_core-4.3.0}/src/eq_chatbot_core/utils/url_validation.py +0 -0
@@ -5,6 +5,18 @@ All notable changes to eq-chatbot-core will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [4.3.0] - 2026-10-12
9
+
10
+ ### Added
11
+
12
+ - Built-in web search: `web_search=True` on `chat_completion` / `stream_completion`. Anthropic and LangDock's `anthropic` backend add Anthropic's server-side search tool (`anthropic_shared.WEB_SEARCH_TOOL`, `web_search_20250305`, at most 5 searches per request); the provider runs and bills the search. Every other provider ignores the flag. `supports_native_web_search()` says which provider has one. Verified live 12.10.2026 with claude-haiku-5-5, directly and through LangDock.
13
+ - `check_model(..., web_search=True)` and `ModelCheck.web_search`: where the provider has a built-in search, one more request with it switched on (the model is not asked to search). `"refused"` usually means the account has web search switched off.
14
+ - `LangDockProvider.agent_info()`: the agent's name, model and switches (web search, image generation, extended thinking, canvas, knowledge, number of actions) from LangDock's Agent Get API; instructions, description and owner are left out.
15
+
16
+ ### Fixed
17
+
18
+ - LangDock agent answers no longer contain source markers such as `【toolu_vrtx_…-0】`, also when a marker is split across deltas, and text written after a tool step starts a new paragraph instead of running into the previous sentence ("…belegt sind.Impressum und …").
19
+
8
20
  ## [4.2.1] - 2026-10-12
9
21
 
10
22
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: eq-chatbot-core
3
- Version: 4.2.1
3
+ Version: 4.3.0
4
4
  Summary: Core library for LLM chatbot integration with multi-provider support (OpenAI, Anthropic, LangDock, OpenRouter, Mammouth, LiteLLM, IONOS, Melious, Privatemode, Local)
5
5
  Project-URL: Homepage, https://www.ownerp.com
6
6
  Project-URL: Documentation, https://github.com/equitania/eq-chatbot-core
@@ -83,7 +83,7 @@ Originally extracted from an Odoo 18 chatbot integration; works standalone witho
83
83
 
84
84
  - **Multi-Provider Support** — OpenAI, Anthropic, LangDock, OpenRouter, Mammouth AI, LiteLLM gateway, IONOS AI Model Hub (EU-hosted), Melious.ai (sovereign EU), Privatemode.ai (end-to-end encrypted, EU), Local (LM Studio/Ollama)
85
85
  - **Unified API** — same interface regardless of provider
86
- - **No built-in model IDs** (v4.0.0) — the model is always the caller's; whether a model accepts `temperature`, `max_completion_tokens` or `reasoning_effort` is learned from the provider at runtime; output limits are read from the provider's own rejection (`probe_output_limit()`, v4.1.0) and requests are capped to them; `check_model()` (v4.2.0) finds out before the first chat what a model accepts — text, tools, images — with a few small requests shaped like a chat turn, tries adjustments for rejections no rule knows, and returns what to persist
86
+ - **No built-in model IDs** (v4.0.0) — the model is always the caller's; whether a model accepts `temperature`, `max_completion_tokens` or `reasoning_effort` is learned from the provider at runtime; output limits are read from the provider's own rejection (`probe_output_limit()`, v4.1.0) and requests are capped to them; `check_model()` (v4.2.0) finds out before the first chat what a model accepts — text, tools, images — with a few small requests shaped like a chat turn, tries adjustments for rejections no rule knows, and returns what to persist; built-in web search with `web_search=True` where the provider has one (v4.3.0, Anthropic and LangDock's anthropic backend)
87
87
  - **Security** — Fernet encryption, prompt-injection detection (direct user input + indirect tool/RAG content), file-upload validation, race-free token-bucket rate limiting
88
88
  - **RAG Pipeline** — chunking, embeddings (incl. Melious.ai and IONOS embedders), Qdrant-backed retrieval, context-window management
89
89
  - **MCP Client** — Streamable HTTP, legacy HTTP/SSE and stdio transports, hardened against DNS rebinding, SSRF, and subprocess env injection; LAN mode for servers on the intranet
@@ -287,7 +287,7 @@ Ursprünglich aus einer Odoo-18-Chatbot-Integration extrahiert; funktioniert sta
287
287
 
288
288
  - **Multi-Provider-Unterstützung** — OpenAI, Anthropic, LangDock, OpenRouter, Mammouth AI, LiteLLM-Gateway, IONOS AI Model Hub (EU-gehostet), Melious.ai (souverän EU), Privatemode.ai (Ende-zu-Ende-verschlüsselt, EU), Local (LM Studio/Ollama)
289
289
  - **Einheitliche API** — gleiche Schnittstelle unabhängig vom Provider
290
- - **Keine eingebauten Modell-IDs** (v4.0.0) — das Modell kommt immer vom Aufrufer; ob ein Modell `temperature`, `max_completion_tokens` oder `reasoning_effort` annimmt, lernt die Bibliothek zur Laufzeit vom Anbieter; `check_model()` (v4.2.0) prüft vor dem ersten Chat mit wenigen kleinen Anfragen in Chat-Form, was ein Modell annimmt – Text, Werkzeuge, Bilder –, probiert bei unbekannten Ablehnungen selbst Anpassungen aus und liefert, was gespeichert werden sollte
290
+ - **Keine eingebauten Modell-IDs** (v4.0.0) — das Modell kommt immer vom Aufrufer; ob ein Modell `temperature`, `max_completion_tokens` oder `reasoning_effort` annimmt, lernt die Bibliothek zur Laufzeit vom Anbieter; `check_model()` (v4.2.0) prüft vor dem ersten Chat mit wenigen kleinen Anfragen in Chat-Form, was ein Modell annimmt – Text, Werkzeuge, Bilder –, probiert bei unbekannten Ablehnungen selbst Anpassungen aus und liefert, was gespeichert werden sollte; eingebaute Websuche mit `web_search=True`, wo der Anbieter eine hat (v4.3.0, Anthropic und LangDocks anthropic-Backend)
291
291
  - **Sicherheit** — Fernet-Verschlüsselung, Prompt-Injection-Erkennung (direkte Nutzereingaben + indirekte Tool-/RAG-Inhalte), File-Upload-Validierung, Race-freies Token-Bucket-Rate-Limiting
292
292
  - **RAG-Pipeline** — Chunking, Embeddings (inkl. Melious.ai- und IONOS-Embedder), Qdrant-basiertes Retrieval, Context-Window-Management
293
293
  - **MCP-Client** — Streamable HTTP, älteres HTTP/SSE und stdio als Transports, gehärtet gegen DNS-Rebinding, SSRF und Subprocess-Env-Injection; LAN-Modus für Server im Intranet
@@ -22,7 +22,7 @@ Originally extracted from an Odoo 18 chatbot integration; works standalone witho
22
22
 
23
23
  - **Multi-Provider Support** — OpenAI, Anthropic, LangDock, OpenRouter, Mammouth AI, LiteLLM gateway, IONOS AI Model Hub (EU-hosted), Melious.ai (sovereign EU), Privatemode.ai (end-to-end encrypted, EU), Local (LM Studio/Ollama)
24
24
  - **Unified API** — same interface regardless of provider
25
- - **No built-in model IDs** (v4.0.0) — the model is always the caller's; whether a model accepts `temperature`, `max_completion_tokens` or `reasoning_effort` is learned from the provider at runtime; output limits are read from the provider's own rejection (`probe_output_limit()`, v4.1.0) and requests are capped to them; `check_model()` (v4.2.0) finds out before the first chat what a model accepts — text, tools, images — with a few small requests shaped like a chat turn, tries adjustments for rejections no rule knows, and returns what to persist
25
+ - **No built-in model IDs** (v4.0.0) — the model is always the caller's; whether a model accepts `temperature`, `max_completion_tokens` or `reasoning_effort` is learned from the provider at runtime; output limits are read from the provider's own rejection (`probe_output_limit()`, v4.1.0) and requests are capped to them; `check_model()` (v4.2.0) finds out before the first chat what a model accepts — text, tools, images — with a few small requests shaped like a chat turn, tries adjustments for rejections no rule knows, and returns what to persist; built-in web search with `web_search=True` where the provider has one (v4.3.0, Anthropic and LangDock's anthropic backend)
26
26
  - **Security** — Fernet encryption, prompt-injection detection (direct user input + indirect tool/RAG content), file-upload validation, race-free token-bucket rate limiting
27
27
  - **RAG Pipeline** — chunking, embeddings (incl. Melious.ai and IONOS embedders), Qdrant-backed retrieval, context-window management
28
28
  - **MCP Client** — Streamable HTTP, legacy HTTP/SSE and stdio transports, hardened against DNS rebinding, SSRF, and subprocess env injection; LAN mode for servers on the intranet
@@ -226,7 +226,7 @@ Ursprünglich aus einer Odoo-18-Chatbot-Integration extrahiert; funktioniert sta
226
226
 
227
227
  - **Multi-Provider-Unterstützung** — OpenAI, Anthropic, LangDock, OpenRouter, Mammouth AI, LiteLLM-Gateway, IONOS AI Model Hub (EU-gehostet), Melious.ai (souverän EU), Privatemode.ai (Ende-zu-Ende-verschlüsselt, EU), Local (LM Studio/Ollama)
228
228
  - **Einheitliche API** — gleiche Schnittstelle unabhängig vom Provider
229
- - **Keine eingebauten Modell-IDs** (v4.0.0) — das Modell kommt immer vom Aufrufer; ob ein Modell `temperature`, `max_completion_tokens` oder `reasoning_effort` annimmt, lernt die Bibliothek zur Laufzeit vom Anbieter; `check_model()` (v4.2.0) prüft vor dem ersten Chat mit wenigen kleinen Anfragen in Chat-Form, was ein Modell annimmt – Text, Werkzeuge, Bilder –, probiert bei unbekannten Ablehnungen selbst Anpassungen aus und liefert, was gespeichert werden sollte
229
+ - **Keine eingebauten Modell-IDs** (v4.0.0) — das Modell kommt immer vom Aufrufer; ob ein Modell `temperature`, `max_completion_tokens` oder `reasoning_effort` annimmt, lernt die Bibliothek zur Laufzeit vom Anbieter; `check_model()` (v4.2.0) prüft vor dem ersten Chat mit wenigen kleinen Anfragen in Chat-Form, was ein Modell annimmt – Text, Werkzeuge, Bilder –, probiert bei unbekannten Ablehnungen selbst Anpassungen aus und liefert, was gespeichert werden sollte; eingebaute Websuche mit `web_search=True`, wo der Anbieter eine hat (v4.3.0, Anthropic und LangDocks anthropic-Backend)
230
230
  - **Sicherheit** — Fernet-Verschlüsselung, Prompt-Injection-Erkennung (direkte Nutzereingaben + indirekte Tool-/RAG-Inhalte), File-Upload-Validierung, Race-freies Token-Bucket-Rate-Limiting
231
231
  - **RAG-Pipeline** — Chunking, Embeddings (inkl. Melious.ai- und IONOS-Embedder), Qdrant-basiertes Retrieval, Context-Window-Management
232
232
  - **MCP-Client** — Streamable HTTP, älteres HTTP/SSE und stdio als Transports, gehärtet gegen DNS-Rebinding, SSRF und Subprocess-Env-Injection; LAN-Modus für Server im Intranet
@@ -1,5 +1,17 @@
1
1
  # Release Notes
2
2
 
3
+ ## Version 4.3.0 (12.10.2026)
4
+
5
+ ### [ADD]
6
+
7
+ - **Eingebaute Websuche:** `web_search=True` bei `chat_completion` und `stream_completion`. Bei Anthropic und LangDocks `anthropic`-Backend wird Anthropics Suchwerkzeug angehängt (höchstens 5 Suchen je Anfrage). Der Anbieter sucht selbst und rechnet die Suchen ab. Alle anderen Anbieter ignorieren den Schalter, `supports_native_web_search()` sagt, wer ihn kennt. Live geprüft am 12.10.2026 mit claude-haiku-5-5, direkt und über LangDock.
8
+ - **Die Modellprüfung prüft die Websuche mit:** Wo es eine eingebaute Suche gibt, schickt `check_model` eine weitere Anfrage mit eingeschalteter Suche. Das Modell wird nicht zum Suchen aufgefordert. Ergebnis in `ModelCheck.web_search`; „abgelehnt“ heißt meist, dass die Websuche im Konto abgeschaltet ist.
9
+ - **`LangDockProvider.agent_info()`** liest Name, Modell und Schalter eines Agenten aus LangDock: Websuche, Bilderzeugung, erweitertes Nachdenken, Canvas, Wissensordner, Anzahl der Aktionen. Anweisungen, Beschreibung und Besitzer bleiben draußen.
10
+
11
+ ### [FIX]
12
+
13
+ - **Agenten-Antworten ohne Quellenmarken:** Marken wie `【toolu_vrtx_…-0】` werden entfernt, auch wenn sie über mehrere Abschnitte verteilt ankommen. Schreibt der Agent nach einem Werkzeugschritt weiter, beginnt ein neuer Absatz, statt dass der Text am vorigen Satz klebt („…belegt sind.Impressum und …“).
14
+
3
15
  ## Version 4.2.1 (12.10.2026)
4
16
 
5
17
  ### [FIX]
@@ -12,6 +12,7 @@ from typing import Any
12
12
  from eq_chatbot_core.providers import param_learning
13
13
  from eq_chatbot_core.providers.anthropic_shared import (
14
14
  ANTHROPIC_LEARNABLE,
15
+ add_web_search,
15
16
  convert_messages,
16
17
  create_message,
17
18
  list_anthropic_models,
@@ -216,6 +217,8 @@ class AnthropicProvider(BaseLLMProvider):
216
217
  temperature: float = 0.7,
217
218
  max_tokens: int | None = None,
218
219
  tools: "list[ToolDefinition] | list[dict[str, Any]] | None" = None,
220
+ *,
221
+ web_search: bool = False,
219
222
  **kwargs: Any,
220
223
  ) -> LLMResponse:
221
224
  """Send a chat completion request to Anthropic with retry on overload."""
@@ -242,6 +245,7 @@ class AnthropicProvider(BaseLLMProvider):
242
245
 
243
246
  if anthropic_tools:
244
247
  params["tools"] = anthropic_tools
248
+ add_web_search(params, web_search)
245
249
 
246
250
  params.update(kwargs)
247
251
 
@@ -312,6 +316,8 @@ class AnthropicProvider(BaseLLMProvider):
312
316
  temperature: float = 0.7,
313
317
  max_tokens: int | None = None,
314
318
  tools: "list[ToolDefinition] | list[dict[str, Any]] | None" = None,
319
+ *,
320
+ web_search: bool = False,
315
321
  **kwargs: Any,
316
322
  ) -> Iterator[StreamChunk]:
317
323
  """Stream a chat completion response from Anthropic with retry on overload."""
@@ -338,6 +344,7 @@ class AnthropicProvider(BaseLLMProvider):
338
344
 
339
345
  if anthropic_tools:
340
346
  params["tools"] = anthropic_tools
347
+ add_web_search(params, web_search)
341
348
 
342
349
  params.update(kwargs)
343
350
 
@@ -467,6 +474,10 @@ class AnthropicProvider(BaseLLMProvider):
467
474
  if last_error:
468
475
  raise self._handle_error(last_error) from last_error
469
476
 
477
+ def supports_native_web_search(self) -> bool:
478
+ """The Messages API's server-side web search (``anthropic_shared.WEB_SEARCH_TOOL``)."""
479
+ return True
480
+
470
481
  def _limit_scope(self) -> str | None:
471
482
  return self._learning_scope(self._endpoint())
472
483
 
@@ -18,6 +18,18 @@ from eq_chatbot_core.providers import param_learning
18
18
 
19
19
  ANTHROPIC_LEARNABLE: tuple[str, ...] = ("temperature",)
20
20
 
21
+ # Anthropic's server-side web search. The model decides when to search; results
22
+ # and citations stay inside the provider's answer, nothing is executed here.
23
+ # Billed per search by the provider; ``max_uses`` caps one request. The newer
24
+ # version tag (web_search_20260209) is refused by LangDock (checked 12.10.2026).
25
+ WEB_SEARCH_TOOL: dict[str, Any] = {"type": "web_search_20250305", "name": "web_search", "max_uses": 5}
26
+
27
+
28
+ def add_web_search(params: dict[str, Any], enabled: Any) -> None:
29
+ """Append the web search server tool to a Messages API request when ``enabled``."""
30
+ if enabled:
31
+ params["tools"] = [*params.get("tools", []), dict(WEB_SEARCH_TOOL)]
32
+
21
33
 
22
34
  def convert_messages(messages: list[dict[str, Any]]) -> list[dict[str, Any]]:
23
35
  """Convert OpenAI-style messages to the Messages API format.
@@ -164,6 +164,10 @@ class ModelCheck:
164
164
  vision: str = "skipped"
165
165
  """The same with a small image."""
166
166
 
167
+ web_search: str = "skipped"
168
+ """The same with the provider's built-in web search switched on; ``"skipped"``
169
+ where the provider has none (``supports_native_web_search``)."""
170
+
167
171
  adjustments: list[str] = field(default_factory=list)
168
172
  """Request adjustments this model needs (``param_learning.LEARNABLE`` names).
169
173
  Persist them and hand them back with ``seed_adjustments`` after a restart."""
@@ -484,6 +488,7 @@ class BaseLLMProvider(ABC):
484
488
  max_tokens: int | None = None,
485
489
  tools: bool = True,
486
490
  vision: bool = True,
491
+ web_search: bool = True,
487
492
  probe_limit: bool = True,
488
493
  **kwargs: Any,
489
494
  ) -> ModelCheck:
@@ -492,8 +497,10 @@ class BaseLLMProvider(ABC):
492
497
  Steps, each a streamed request shaped like a chat turn (system and user
493
498
  message, the caller's ``temperature`` and extra ``kwargs``, an output limit
494
499
  of at most ``CHECK_MAX_TOKENS``): plain text, then with one function tool
495
- (``tools``), then with a small image (``vision``). Tools and image are
496
- only tried once plain text works. Finally the output limit is asked for
500
+ (``tools``), then with a small image (``vision``), then with the
501
+ provider's built-in web search switched on (``web_search``, only where
502
+ ``supports_native_web_search``; the model is not asked to search, so it
503
+ costs no search). These are only tried once plain text works. Finally the output limit is asked for
497
504
  (``probe_limit``, see ``probe_output_limit``).
498
505
 
499
506
  A rejection the library does not recognise is explored: the request is
@@ -518,9 +525,9 @@ class BaseLLMProvider(ABC):
518
525
  limit = min(max_tokens or CHECK_MAX_TOKENS, CHECK_MAX_TOKENS)
519
526
  system = {"role": "system", "content": CHECK_SYSTEM}
520
527
 
521
- def step(name: str, user_content: Any, step_tools: list[dict[str, Any]] | None) -> str:
528
+ def step(name: str, user_content: Any, step_tools: list[dict[str, Any]] | None, **extra: Any) -> str:
522
529
  messages = [system, {"role": "user", "content": user_content}]
523
- state, message = self._check_step(model, messages, temperature, limit, step_tools, kwargs)
530
+ state, message = self._check_step(model, messages, temperature, limit, step_tools, {**kwargs, **extra})
524
531
  setattr(result, name, state)
525
532
  if message:
526
533
  result.messages[name] = message
@@ -532,6 +539,8 @@ class BaseLLMProvider(ABC):
532
539
  if vision:
533
540
  image = self._check_image_part(check_image_png())
534
541
  step("vision", [{"type": "text", "text": "Which colour is this image?"}, image], None)
542
+ if web_search and self.supports_native_web_search():
543
+ step("web_search", "Reply with OK.", None, web_search=True)
535
544
  if probe_limit:
536
545
  try:
537
546
  self.probe_output_limit(model)
@@ -574,6 +583,15 @@ class BaseLLMProvider(ABC):
574
583
 
575
584
  return scrub_secrets(str(error))[:500]
576
585
 
586
+ def supports_native_web_search(self) -> bool:
587
+ """Whether this provider offers a built-in web search (``web_search=True``).
588
+
589
+ The search runs at the provider, which also bills it. Whether a given
590
+ model and account may use it is found out by ``check_model``.
591
+ Providers without one ignore ``web_search``.
592
+ """
593
+ return False
594
+
577
595
  def _check_image_part(self, png_base64: str) -> dict[str, Any]:
578
596
  """The image of the vision step, in the message format this provider expects."""
579
597
  return {"type": "image_url", "image_url": {"url": f"data:image/png;base64,{png_base64}"}}
@@ -13,6 +13,7 @@ Documentation: https://docs.langdock.com/api-endpoints/api-introduction
13
13
 
14
14
  import json
15
15
  import logging
16
+ import re
16
17
  from collections.abc import Iterable, Iterator
17
18
  from contextlib import ExitStack
18
19
  from typing import Any
@@ -21,6 +22,7 @@ import httpx2
21
22
 
22
23
  from eq_chatbot_core.providers import param_learning
23
24
  from eq_chatbot_core.providers.anthropic_shared import (
25
+ add_web_search,
24
26
  convert_messages,
25
27
  create_message,
26
28
  list_anthropic_models,
@@ -114,6 +116,60 @@ def _iter_sse_data(lines: Iterable[str]) -> Iterator[dict[str, Any]]:
114
116
  yield event
115
117
 
116
118
 
119
+ # Source markers an agent leaves in its text after a search, e.g.
120
+ # "75173 【toolu_vrtx_01LU…-0】" (LangDock, 12.10.2026) or OpenAI's "【4:0†source】".
121
+ # They point into the agent's own tool results, which the caller never sees.
122
+ _SOURCE_MARKER = re.compile(r"[ \t]?【[^】\n]{0,200}?(?:toolu_|†|:\d)[^】\n]{0,200}】")
123
+ _MARKER_HOLD = 300
124
+
125
+
126
+ class _AgentText:
127
+ """The user-visible text of an agent's event stream.
128
+
129
+ Removes source markers, also when one is split across deltas, and starts a
130
+ new paragraph when the agent writes again after a tool step — LangDock sends
131
+ "…belegt sind." and "Impressum und…" from two steps with nothing between.
132
+ """
133
+
134
+ def __init__(self) -> None:
135
+ self._held = ""
136
+ self._wrote = False
137
+ self._new_step = False
138
+
139
+ def feed(self, event: dict[str, Any]) -> str:
140
+ kind = event.get("type")
141
+ if kind == "start-step" and self._wrote:
142
+ self._new_step = True
143
+ return ""
144
+ if kind != "text-delta":
145
+ return ""
146
+ delta = event.get("delta") or ""
147
+ if not delta:
148
+ return ""
149
+ if self._new_step:
150
+ self._new_step = False
151
+ delta = "\n\n" + delta.lstrip()
152
+ return self._release(self._held + delta)
153
+
154
+ def flush(self) -> str:
155
+ text, self._held = _SOURCE_MARKER.sub("", self._held), ""
156
+ return text
157
+
158
+ def _release(self, text: str) -> str:
159
+ text = _SOURCE_MARKER.sub("", text)
160
+ start = text.rfind("【")
161
+ if start > 0 and text[start - 1] in " \t":
162
+ start -= 1 # the space before a marker goes with it
163
+ if start != -1 and "】" not in text[start:] and len(text) - start < _MARKER_HOLD:
164
+ # Possibly the beginning of a marker: hold it until it closes.
165
+ text, self._held = text[:start], text[start:]
166
+ else:
167
+ self._held = ""
168
+ if text:
169
+ self._wrote = True
170
+ return text
171
+
172
+
117
173
  def _agent_error_message(status_code: int, detail: str) -> str:
118
174
  """Turn an Agent API error body into an actionable, German-language message.
119
175
 
@@ -281,6 +337,50 @@ class LangDockProvider(BaseLLMProvider):
281
337
  # The agent backend's model is configured in LangDock; nothing is learned there.
282
338
  return None if self.backend == "agent" else self._learning_scope(self._get_backend_url())
283
339
 
340
+ def agent_info(self) -> dict[str, Any]:
341
+ """What the configured agent can do, from LangDock's Agent Get API.
342
+
343
+ Returns ``name``, ``model`` (the model ID set in LangDock, ``None`` on
344
+ "Auto"), ``web_search``, ``image_generation``, ``extended_thinking``,
345
+ ``canvas``, ``knowledge`` (knowledge folders attached) and ``actions``
346
+ (number of LangDock actions). Instructions, description and owner are
347
+ left out on purpose. Raises ``ProviderError`` when the agent cannot be
348
+ read (no access, wrong workspace, network).
349
+ """
350
+ if self.backend != "agent" or not self.agent_id:
351
+ raise ProviderError("agent_info needs the agent backend and an agent ID", provider="langdock")
352
+ try:
353
+ response = self.http_client.get("/get", params={"agentId": self.agent_id}, timeout=30.0)
354
+ except httpx2.HTTPError as e:
355
+ raise ProviderError(f"Agent HTTP error: {_scrub(str(e))}", provider="langdock") from e
356
+ if response.status_code != 200:
357
+ detail = _safe_detail(response.text)
358
+ raise ProviderError(
359
+ _agent_error_message(response.status_code, detail),
360
+ provider="langdock",
361
+ status_code=response.status_code,
362
+ )
363
+ agent = (response.json() or {}).get("agent") or {}
364
+ return {
365
+ "name": agent.get("name") or "",
366
+ "model": agent.get("model"),
367
+ "web_search": bool(agent.get("webSearchEnabled")),
368
+ "image_generation": bool(agent.get("imageGenerationEnabled")),
369
+ "extended_thinking": bool(agent.get("extendedThinking")),
370
+ "canvas": bool(agent.get("canvasEnabled")),
371
+ "knowledge": bool(agent.get("knowledgeFolderIds")),
372
+ "actions": len(agent.get("actions") or []),
373
+ }
374
+
375
+ def supports_native_web_search(self) -> bool:
376
+ """The anthropic backend passes Anthropic's server-side web search through.
377
+
378
+ LangDock's openai endpoints refuse hosted tools ("Only function tools are
379
+ allowed", checked 12.10.2026); an agent searches if it is set up to in
380
+ LangDock (``agent_info``).
381
+ """
382
+ return self.backend == "anthropic"
383
+
284
384
  def _check_image_part(self, png_base64: str) -> dict[str, Any]:
285
385
  """The anthropic backend takes the Messages API's image block, the others OpenAI's."""
286
386
  if self.backend == "anthropic":
@@ -383,6 +483,7 @@ class LangDockProvider(BaseLLMProvider):
383
483
  tools: "list[ToolDefinition] | list[dict[str, Any]] | None" = None,
384
484
  *,
385
485
  reasoning_effort: str | None = None,
486
+ web_search: bool = False,
386
487
  **kwargs: Any,
387
488
  ) -> LLMResponse:
388
489
  """
@@ -402,7 +503,9 @@ class LangDockProvider(BaseLLMProvider):
402
503
  messages, model, temperature, max_tokens, tools, reasoning_effort, **kwargs
403
504
  )
404
505
  elif self.backend == "anthropic":
405
- return self._anthropic_chat_completion(messages, model, temperature, max_tokens, tools, **kwargs)
506
+ return self._anthropic_chat_completion(
507
+ messages, model, temperature, max_tokens, tools, web_search=web_search, **kwargs
508
+ )
406
509
  elif self.backend == "google":
407
510
  return self._google_chat_completion(messages, model, temperature, max_tokens, **kwargs)
408
511
  elif self.backend == "codestral":
@@ -581,16 +684,16 @@ class LangDockProvider(BaseLLMProvider):
581
684
  content_parts: list[str] = []
582
685
  model_name = ""
583
686
  metadata: dict[str, Any] = {}
687
+ text = _AgentText()
584
688
 
585
689
  for event in self._agent_request_events(agent_messages):
586
- kind = event.get("type")
587
- if kind == "text-delta":
588
- delta = event.get("delta") or ""
589
- if delta:
590
- content_parts.append(delta)
591
- elif kind == "start":
690
+ if event.get("type") == "start":
592
691
  metadata = event.get("messageMetadata") or {}
593
692
  model_name = metadata.get("modelName") or ""
693
+ piece = text.feed(event)
694
+ if piece:
695
+ content_parts.append(piece)
696
+ content_parts.append(text.flush())
594
697
 
595
698
  content = "".join(content_parts)
596
699
  if not content:
@@ -627,6 +730,8 @@ class LangDockProvider(BaseLLMProvider):
627
730
  temperature: float,
628
731
  max_tokens: int | None,
629
732
  tools: list[dict[str, Any]] | None,
733
+ *,
734
+ web_search: bool = False,
630
735
  **kwargs: Any,
631
736
  ) -> LLMResponse:
632
737
  """Anthropic-compatible chat completion."""
@@ -659,6 +764,7 @@ class LangDockProvider(BaseLLMProvider):
659
764
  )
660
765
  if anthropic_tools:
661
766
  params["tools"] = anthropic_tools
767
+ add_web_search(params, web_search)
662
768
 
663
769
  params.update(kwargs)
664
770
 
@@ -879,6 +985,7 @@ class LangDockProvider(BaseLLMProvider):
879
985
  tools: "list[ToolDefinition] | list[dict[str, Any]] | None" = None,
880
986
  *,
881
987
  reasoning_effort: str | None = None,
988
+ web_search: bool = False,
882
989
  **kwargs: Any,
883
990
  ) -> Iterator[StreamChunk]:
884
991
  """
@@ -898,7 +1005,9 @@ class LangDockProvider(BaseLLMProvider):
898
1005
  messages, model, temperature, max_tokens, tools, reasoning_effort, **kwargs
899
1006
  )
900
1007
  elif self.backend == "anthropic":
901
- yield from self._anthropic_stream_completion(messages, model, temperature, max_tokens, tools, **kwargs)
1008
+ yield from self._anthropic_stream_completion(
1009
+ messages, model, temperature, max_tokens, tools, web_search=web_search, **kwargs
1010
+ )
902
1011
  elif self.backend == "google":
903
1012
  yield from self._google_stream_completion(messages, model, temperature, max_tokens, **kwargs)
904
1013
  elif self.backend == "codestral":
@@ -974,21 +1083,20 @@ class LangDockProvider(BaseLLMProvider):
974
1083
  kwargs.pop("max_tokens", None)
975
1084
 
976
1085
  emitted = 0
1086
+ text = _AgentText()
977
1087
  for event in self._agent_request_events(agent_messages):
978
1088
  kind = event.get("type")
979
-
980
- if kind == "text-delta":
981
- delta = event.get("delta") or ""
982
- if delta:
983
- emitted += 1
984
- yield StreamChunk(
985
- content=delta,
986
- is_final=False,
987
- finish_reason=None,
988
- input_tokens=0,
989
- output_tokens=0,
990
- )
991
- elif kind == "start":
1089
+ piece = text.feed(event)
1090
+ if piece:
1091
+ emitted += 1
1092
+ yield StreamChunk(
1093
+ content=piece,
1094
+ is_final=False,
1095
+ finish_reason=None,
1096
+ input_tokens=0,
1097
+ output_tokens=0,
1098
+ )
1099
+ if kind == "start":
992
1100
  model_name = (event.get("messageMetadata") or {}).get("modelName")
993
1101
  if model_name:
994
1102
  _logger.info(f"Agent stream: answering with {model_name}")
@@ -996,6 +1104,11 @@ class LangDockProvider(BaseLLMProvider):
996
1104
  # and data-* carry no user-visible text; ignoring unknown types
997
1105
  # keeps a protocol addition from breaking us.
998
1106
 
1107
+ rest = text.flush()
1108
+ if rest:
1109
+ emitted += 1
1110
+ yield StreamChunk(content=rest, is_final=False, finish_reason=None, input_tokens=0, output_tokens=0)
1111
+
999
1112
  if not emitted:
1000
1113
  _logger.warning("Agent stream: no text-delta events in the response")
1001
1114
 
@@ -1026,6 +1139,8 @@ class LangDockProvider(BaseLLMProvider):
1026
1139
  temperature: float,
1027
1140
  max_tokens: int | None,
1028
1141
  tools: list[dict[str, Any]] | None,
1142
+ *,
1143
+ web_search: bool = False,
1029
1144
  **kwargs: Any,
1030
1145
  ) -> Iterator[StreamChunk]:
1031
1146
  """Anthropic-compatible streaming."""
@@ -1057,6 +1172,7 @@ class LangDockProvider(BaseLLMProvider):
1057
1172
  )
1058
1173
  if anthropic_tools:
1059
1174
  params["tools"] = anthropic_tools
1175
+ add_web_search(params, web_search)
1060
1176
 
1061
1177
  params.update(kwargs)
1062
1178
 
@@ -323,6 +323,8 @@ class OpenAICompatibleProvider(BaseLLMProvider):
323
323
  temperature: float = 0.7,
324
324
  max_tokens: int | None = None,
325
325
  tools: "list[ToolDefinition] | list[dict[str, Any]] | None" = None,
326
+ *,
327
+ web_search: bool = False,
326
328
  **kwargs: Any,
327
329
  ) -> LLMResponse:
328
330
  """Send a chat completion request to the gateway."""
@@ -394,6 +396,8 @@ class OpenAICompatibleProvider(BaseLLMProvider):
394
396
  temperature: float = 0.7,
395
397
  max_tokens: int | None = None,
396
398
  tools: "list[ToolDefinition] | list[dict[str, Any]] | None" = None,
399
+ *,
400
+ web_search: bool = False,
397
401
  **kwargs: Any,
398
402
  ) -> Iterator[StreamChunk]:
399
403
  """Stream a chat completion response from the gateway.
@@ -1,3 +1,3 @@
1
1
  """Version information for eq-chatbot-core."""
2
2
 
3
- __version__ = "4.2.1"
3
+ __version__ = "4.3.0"
File without changes