Skip to content

Commit 12e2ff3

Browse files
author
Oracles Technologies LLC
committed
feat(providers): add DeepSeek, Mistral AI, Perplexity + refresh xAI, OpenAI, Anthropic, Gemini (v2.6.4)
New providers (v2.6.4): - deepseek_provider: DeepSeek V4 (deepseek-v4-flash, deepseek-v4-pro), three-layer agentic protection - mistral_provider: Mistral AI (mistral-large, codestral, devstral, magistral, 22 models), three-layer protection - perplexity_provider: Perplexity Sonar (sonar, sonar-pro, sonar-reasoning-pro, sonar-deep-research), web-grounded Updated providers: - xai_provider v1.1.0: grok-4.3, grok-4.20 reasoning/non-reasoning, grok-build-0.1, grok-imagine-* (16 models) - openai_provider v1.1.0: GPT-5.5, gpt-5.3-codex, o3, o3-mini current model IDs - anthropic_provider v1.1.0: claude-opus-4-7, claude-sonnet-4-6, claude-haiku-4-5; retirement note for 4-0 series - gemini_provider v1.1.0: gemini-3.5-flash, gemini-3.1-pro-preview, gemini-3.1-flash-* current model IDs Infrastructure: - providers/__init__.py v1.1.0: exports for all three new providers - community_guardian.py: protect_deepseek, protect_mistral, protect_perplexity convenience functions - pyproject.toml: [xai], [deepseek], [mistral], [perplexity] optional-dependency extras - Tests: 138 new tests (46 per provider), 1806 total passing - README: provider install examples and code snippets for all new providers
1 parent 6ae65cc commit 12e2ff3

16 files changed

Lines changed: 3366 additions & 28 deletions

README.md

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,16 @@ pip install ethicore-engine-guardian
4040

4141
With provider integrations:
4242
```bash
43-
pip install "ethicore-engine-guardian[openai]"
44-
pip install "ethicore-engine-guardian[anthropic]"
45-
pip install "ethicore-engine-guardian[openai,anthropic]"
43+
# Cloud (OpenAI-compatible)
44+
pip install "ethicore-engine-guardian[openai]" # OpenAI (GPT-5.5, o3, Codex)
45+
pip install "ethicore-engine-guardian[xai]" # xAI / Grok (grok-4.3, grok-build)
46+
pip install "ethicore-engine-guardian[deepseek]" # DeepSeek (deepseek-v4-flash, v4-pro)
47+
pip install "ethicore-engine-guardian[mistral]" # Mistral AI (mistral-large, codestral, devstral)
48+
pip install "ethicore-engine-guardian[perplexity]" # Perplexity Sonar (web-grounded models)
49+
50+
# Cloud (native SDK)
51+
pip install "ethicore-engine-guardian[anthropic]" # Anthropic (claude-opus-4-7, claude-sonnet-4-6)
52+
pip install "ethicore-engine-guardian[google]" # Google Gemini (gemini-3.5-flash, gemini-3.1-pro)
4653
```
4754

4855
With visual analysis (images):
@@ -401,6 +408,71 @@ guardian = Guardian(config=GuardianConfig(api_key="eg_live_..."))
401408
client = guardian.wrap(anthropic.Anthropic())
402409
```
403410

411+
### xAI / Grok
412+
413+
```python
414+
import openai
415+
from ethicore_guardian import Guardian, GuardianConfig
416+
417+
guardian = Guardian(config=GuardianConfig(api_key="eg_live_..."))
418+
client = guardian.wrap(
419+
openai.OpenAI(api_key="xai-...", base_url="https://api.x.ai/v1")
420+
)
421+
response = client.chat.completions.create(
422+
model="grok-4.3",
423+
messages=[{"role": "user", "content": user_input}]
424+
)
425+
```
426+
427+
### DeepSeek
428+
429+
```python
430+
import openai
431+
from ethicore_guardian import Guardian, GuardianConfig
432+
433+
guardian = Guardian(config=GuardianConfig(api_key="eg_live_..."))
434+
client = guardian.wrap(
435+
openai.OpenAI(api_key="sk-...", base_url="https://api.deepseek.com")
436+
)
437+
response = client.chat.completions.create(
438+
model="deepseek-v4-flash",
439+
messages=[{"role": "user", "content": user_input}]
440+
)
441+
```
442+
443+
### Mistral AI
444+
445+
```python
446+
import openai
447+
from ethicore_guardian import Guardian, GuardianConfig
448+
449+
guardian = Guardian(config=GuardianConfig(api_key="eg_live_..."))
450+
client = guardian.wrap(
451+
openai.OpenAI(api_key="...", base_url="https://api.mistral.ai/v1")
452+
)
453+
response = client.chat.completions.create(
454+
model="mistral-large-latest",
455+
messages=[{"role": "user", "content": user_input}]
456+
)
457+
```
458+
459+
### Perplexity
460+
461+
```python
462+
import openai
463+
from ethicore_guardian import Guardian, GuardianConfig
464+
465+
guardian = Guardian(config=GuardianConfig(api_key="eg_live_..."))
466+
client = guardian.wrap(
467+
openai.OpenAI(api_key="pplx-...", base_url="https://api.perplexity.ai")
468+
)
469+
# Guardian scans the user prompt before Perplexity fetches web sources
470+
response = client.chat.completions.create(
471+
model="sonar-pro",
472+
messages=[{"role": "user", "content": user_input}]
473+
)
474+
```
475+
404476
### Ollama (local LLMs)
405477

406478
```python

ethicore_guardian/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88

99
# Version information
10-
__version__ = "2.6.3"
10+
__version__ = "2.6.4"
1111
__author__ = "Oracles Technologies LLC"
1212

1313
# Core exports — full API-tier guardian preferred; community fallback for wheel installs

ethicore_guardian/community_guardian.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,11 @@ def wrap(self, client: Any) -> Any:
510510
"""
511511
Wrap an AI provider client so every request is scanned first.
512512
513-
Community edition supports OpenAI, xAI/Grok, and Azure OpenAI
514-
clients (anything with a ``.chat.completions.create`` interface).
513+
Community edition supports any OpenAI-compatible client
514+
(OpenAI, xAI/Grok, DeepSeek, Mistral AI, Perplexity, Azure OpenAI)
515+
and anything with a ``.chat.completions.create`` interface.
516+
Full three-layer agentic protection (tool result and tool call scanning)
517+
requires the API tier.
515518
"""
516519
return _WrappedClient(client, self)
517520

@@ -609,6 +612,27 @@ def protect_xai(client: Any, api_key: Optional[str] = None) -> Any:
609612
return Guardian(api_key=api_key).wrap(client)
610613

611614

615+
def protect_deepseek(client: Any, api_key: Optional[str] = None) -> Any:
616+
"""Wrap a DeepSeek client with Guardian protection."""
617+
return Guardian(api_key=api_key).wrap(client)
618+
619+
620+
def protect_mistral(client: Any, api_key: Optional[str] = None) -> Any:
621+
"""Wrap a Mistral AI client with Guardian protection."""
622+
return Guardian(api_key=api_key).wrap(client)
623+
624+
625+
def protect_perplexity(client: Any, api_key: Optional[str] = None) -> Any:
626+
"""
627+
Wrap a Perplexity Sonar client with Guardian protection.
628+
629+
Guardian scans the user-supplied prompt before it reaches Perplexity.
630+
Web-fetched content within Perplexity's inference pipeline is outside
631+
the API boundary. Full three-layer agentic protection requires the API tier.
632+
"""
633+
return Guardian(api_key=api_key).wrap(client)
634+
635+
612636
def protect_azure(client: Any, api_key: Optional[str] = None) -> Any:
613637
"""Wrap an Azure OpenAI client with Guardian protection."""
614638
return Guardian(api_key=api_key).wrap(client)

ethicore_guardian/providers/__init__.py

Lines changed: 72 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,35 @@
11
"""
22
Ethicore Engine™ - Guardian SDK - Providers Package
33
AI provider integrations for Guardian SDK
4-
"""
54
6-
# This makes the providers directory a proper Python package.
7-
# Providers are importable either directly from their module or from here.
5+
Supported providers:
6+
Local / self-hosted:
7+
LM Studio, llama.cpp, LocalAI, Jan.ai — local_openai_compat_provider
8+
Ollama — guardian_ollama_provider
9+
10+
Cloud (OpenAI-compatible API):
11+
xAI / Grok — xai_provider
12+
DeepSeek — deepseek_provider
13+
Mistral AI — mistral_provider
14+
Perplexity — perplexity_provider
15+
16+
Cloud (native API):
17+
OpenAI — openai_provider
18+
Anthropic — anthropic_provider
19+
Google Gemini — gemini_provider
20+
Azure OpenAI — azure_provider
21+
AWS Bedrock — bedrock_provider
22+
23+
Meta-provider:
24+
LiteLLM (140+ backends) — litellm_provider
25+
26+
Framework integrations:
27+
LangChain callback — langchain_callback
28+
"""
829

9-
__version__ = "1.0.0"
30+
__version__ = "1.1.0"
1031

1132
# ── Local OpenAI-compatible providers ────────────────────────────────────────
12-
# LM Studio, llama.cpp server, LocalAI, Jan.ai — all share the same
13-
# OpenAI-compatible REST API, covered by a single implementation.
1433
from .local_openai_compat_provider import (
1534
LocalOpenAICompatConfig,
1635
LocalOpenAICompatProvider,
@@ -31,25 +50,66 @@
3150
LocalProviderError,
3251
)
3352

53+
# ── DeepSeek provider ─────────────────────────────────────────────────────────
54+
from .deepseek_provider import (
55+
DeepSeekProvider,
56+
ProtectedDeepSeekClient,
57+
create_protected_deepseek_client,
58+
DEEPSEEK_BASE_URL,
59+
DEEPSEEK_MODELS,
60+
)
61+
62+
# ── Mistral AI provider ───────────────────────────────────────────────────────
63+
from .mistral_provider import (
64+
MistralProvider,
65+
ProtectedMistralClient,
66+
create_protected_mistral_client,
67+
MISTRAL_BASE_URL,
68+
MISTRAL_MODELS,
69+
)
70+
71+
# ── Perplexity provider ───────────────────────────────────────────────────────
72+
from .perplexity_provider import (
73+
PerplexityProvider,
74+
ProtectedPerplexityClient,
75+
create_protected_perplexity_client,
76+
PERPLEXITY_BASE_URL,
77+
PERPLEXITY_MODELS,
78+
)
79+
3480
__all__ = [
35-
# Config
81+
# ── Local OpenAI-compatible ───────────────────────────────────────────────
3682
"LocalOpenAICompatConfig",
37-
# Base provider
3883
"LocalOpenAICompatProvider",
39-
# Named providers
4084
"LMStudioProvider",
4185
"LlamaCppProvider",
4286
"LocalAIProvider",
4387
"JanAIProvider",
44-
# Wrapped clients
4588
"ProtectedLocalClient",
4689
"ProtectedAsyncLocalClient",
47-
# Convenience factories
4890
"create_protected_lmstudio_client",
4991
"create_protected_llamacpp_client",
5092
"create_protected_localai_client",
5193
"create_protected_janai_client",
52-
# Exceptions
94+
# ── DeepSeek ─────────────────────────────────────────────────────────────
95+
"DeepSeekProvider",
96+
"ProtectedDeepSeekClient",
97+
"create_protected_deepseek_client",
98+
"DEEPSEEK_BASE_URL",
99+
"DEEPSEEK_MODELS",
100+
# ── Mistral ───────────────────────────────────────────────────────────────
101+
"MistralProvider",
102+
"ProtectedMistralClient",
103+
"create_protected_mistral_client",
104+
"MISTRAL_BASE_URL",
105+
"MISTRAL_MODELS",
106+
# ── Perplexity ────────────────────────────────────────────────────────────
107+
"PerplexityProvider",
108+
"ProtectedPerplexityClient",
109+
"create_protected_perplexity_client",
110+
"PERPLEXITY_BASE_URL",
111+
"PERPLEXITY_MODELS",
112+
# ── Exceptions (re-exported from local_openai_compat_provider) ────────────
53113
"ThreatBlockedException",
54114
"ThreatChallengeException",
55115
"ToolOutputBlockedException",

ethicore_guardian/providers/anthropic_provider.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
"""
22
Ethicore Engine™ - Guardian SDK — Anthropic Provider
33
Mirrors the OpenAI provider pattern for the Anthropic Messages API.
4-
Version: 1.0.0
4+
Version: 1.1.0
5+
6+
Current Claude model IDs (May 2026):
7+
claude-opus-4-7 — Most capable; 1M context, 128k output (current flagship)
8+
claude-sonnet-4-6 — Speed + intelligence balance; 1M context
9+
claude-haiku-4-5 — Fastest; 200k context
10+
11+
Retiring June 15 2026 (migrate off these):
12+
claude-sonnet-4-0 / claude-opus-4-0 (claude-*-4-20250514 snapshots)
513
614
Copyright © 2026 Oracles Technologies LLC
715
All Rights Reserved
@@ -415,7 +423,7 @@ def create_protected_anthropic_client(
415423
guardian_api_key="ethicore-...",
416424
)
417425
response = client.messages.create(
418-
model="claude-opus-4-5",
426+
model="claude-opus-4-7",
419427
max_tokens=1024,
420428
messages=[{"role": "user", "content": "Hello"}],
421429
)

0 commit comments

Comments
 (0)