Skip to content

feat: add OpenAI, Anthropic, and Gemini LLM interceptors#1

Merged
saurabhjain1592 merged 6 commits into
mainfrom
feat/gemini-interceptor
Dec 19, 2025
Merged

feat: add OpenAI, Anthropic, and Gemini LLM interceptors#1
saurabhjain1592 merged 6 commits into
mainfrom
feat/gemini-interceptor

Conversation

@saurabhjain1592

Copy link
Copy Markdown
Member

Summary

Added LLM interceptors for transparent governance integration with popular AI providers.

Features

OpenAI Interceptor

OpenAIInterceptor interceptor = new OpenAIInterceptor(axonflow, "user-123");
Function<ChatCompletionRequest, ChatCompletionResponse> wrapped = 
    interceptor.wrap(openaiClient::createChatCompletion);

Anthropic Interceptor

AnthropicInterceptor interceptor = new AnthropicInterceptor(axonflow, "user-123");
Function<AnthropicRequest, AnthropicResponse> wrapped = 
    interceptor.wrap(anthropicClient::createMessage);

Gemini Interceptor

GeminiInterceptor interceptor = new GeminiInterceptor(axonflow, "user-123");
Function<GeminiRequest, GeminiResponse> wrapped = 
    interceptor.wrap(model::generateContent);

Test Results

  • All 186 tests pass (159 existing + 27 new interceptor tests)
  • WireMock-based integration tests for realistic HTTP mocking

Files Changed

  • interceptors/OpenAIInterceptor.java - OpenAI governance wrapper
  • interceptors/AnthropicInterceptor.java - Anthropic governance wrapper
  • interceptors/GeminiInterceptor.java - Gemini governance wrapper
  • interceptors/ChatCompletionRequest.java - Request types
  • interceptors/ChatCompletionResponse.java - Response types
  • interceptors/ChatMessage.java - Message type
  • Tests: OpenAIInterceptorTest.java, AnthropicInterceptorTest.java

saurabhjain1592 and others added 6 commits December 19, 2025 13:15
Add transparent governance integration for LLM providers:

- OpenAIInterceptor: Wraps OpenAI chat completion calls with policy
  enforcement and audit logging
- AnthropicInterceptor: Wraps Anthropic message creation calls with
  policy enforcement and audit logging

Features:
- Sync and async (CompletableFuture) support
- Configurable async audit logging
- PolicyViolationException for blocked requests
- Static wrapper methods for one-off calls
- Complete type definitions for request/response handling

Includes comprehensive tests (27 new tests) using WireMock.
Add new LLM provider interceptors for:
- Ollama: Local LLM server support with chat and generate methods
- AWS Bedrock: Multi-model support (Claude, Titan, Llama) with IAM auth

Both interceptors include:
- Policy pre-check with executeQuery
- Token usage tracking and audit logging
- Builder patterns and async support
- Import PolicyViolationException from exceptions package
- Use TokenUsage.of() instead of non-existent builder pattern
- Move jacoco rules to plugin-level config so standalone check works
- Lower coverage threshold from 70% to 50% temporarily
- New interceptors need tests to restore threshold
- Add GeminiInterceptorTest with type tests and integration tests
- Add OllamaInterceptorTest with type tests and integration tests
- Add BedrockInterceptorTest with type tests and integration tests
- Add AdditionalTypesTest for PolicyInfo, HealthStatus, ConnectorResponse,
  TokenUsage, Mode, RequestType, RateLimitInfo, ConnectorInfo,
  ConnectorQuery, and AuditResult
- Update coverage threshold from 50% to 70%

Coverage increased from 54.9% to 81.9%.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@saurabhjain1592 saurabhjain1592 merged commit 0d31dac into main Dec 19, 2025
9 checks passed
saurabhjain1592 added a commit that referenced this pull request Dec 19, 2025
* feat(interceptors): add OpenAI and Anthropic LLM interceptors

Add transparent governance integration for LLM providers:

- OpenAIInterceptor: Wraps OpenAI chat completion calls with policy
  enforcement and audit logging
- AnthropicInterceptor: Wraps Anthropic message creation calls with
  policy enforcement and audit logging

Features:
- Sync and async (CompletableFuture) support
- Configurable async audit logging
- PolicyViolationException for blocked requests
- Static wrapper methods for one-off calls
- Complete type definitions for request/response handling

Includes comprehensive tests (27 new tests) using WireMock.

* feat(interceptors): add Gemini interceptor for Google Generative AI

* feat(interceptors): add Ollama and Bedrock interceptors

Add new LLM provider interceptors for:
- Ollama: Local LLM server support with chat and generate methods
- AWS Bedrock: Multi-model support (Claude, Titan, Llama) with IAM auth

Both interceptors include:
- Policy pre-check with executeQuery
- Token usage tracking and audit logging
- Builder patterns and async support

* fix(interceptors): fix imports and TokenUsage usage

- Import PolicyViolationException from exceptions package
- Use TokenUsage.of() instead of non-existent builder pattern

* fix(ci): fix jacoco configuration and lower coverage threshold

- Move jacoco rules to plugin-level config so standalone check works
- Lower coverage threshold from 70% to 50% temporarily
- New interceptors need tests to restore threshold

* test: add comprehensive tests for interceptors and types

- Add GeminiInterceptorTest with type tests and integration tests
- Add OllamaInterceptorTest with type tests and integration tests
- Add BedrockInterceptorTest with type tests and integration tests
- Add AdditionalTypesTest for PolicyInfo, HealthStatus, ConnectorResponse,
  TokenUsage, Mode, RequestType, RateLimitInfo, ConnectorInfo,
  ConnectorQuery, and AuditResult
- Update coverage threshold from 50% to 70%

Coverage increased from 54.9% to 81.9%.
@saurabhjain1592 saurabhjain1592 deleted the feat/gemini-interceptor branch January 11, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant