As a developer, I want the Cog’s AI-calling logic to depend on an abstract interface rather than directly on OpenAI, so that we can swap in other AI providers (Anthropic, Azure, local LLM, etc.) without touching the core code.
Description
Define an IAiService interface (or abstract base class) with methods for chat completions, embeddings, and function calls.
Refactor the existing OpenAI logic into a concrete OpenAiService that implements IAiService.
Update reginaldCog to accept an IAiService instance via its constructor (or a setter), and replace all direct openai.* calls with self.ai_service.*.
Add configuration (global or guild) to select which IAiService implementation to use at runtime (defaulting to OpenAI).
[OPTIONAL] Provide a mock or stub IAiService implementation for testing.
All direct openai.* calls are moved into OpenAiService : IAiService.
reginaldCog only interacts with IAiService and no longer imports openai.
Configuration allows switching providers without code changes.
A mock IAiService is available and used in unit tests to simulate responses.
Bot behavior remains unchanged when using OpenAiService.
Definition of Done
Code reviewed, demo'ed & accepted before merge
Code merged
Docs updated
# User Story
As a developer, I want the Cog’s AI-calling logic to depend on an abstract interface rather than directly on OpenAI, so that we can swap in other AI providers (Anthropic, Azure, local LLM, etc.) without touching the core code.
## Description
- Define an IAiService interface (or abstract base class) with methods for chat completions, embeddings, and function calls.
- Refactor the existing OpenAI logic into a concrete OpenAiService that implements IAiService.
- Update reginaldCog to accept an IAiService instance via its constructor (or a setter), and replace all direct openai.* calls with self.ai_service.*.
- Add configuration (global or guild) to select which IAiService implementation to use at runtime (defaulting to OpenAI).
- [OPTIONAL] Provide a mock or stub IAiService implementation for testing.
##
Acceptance Criteria
1. An IAiService interface exists with methods for:
chat_completion(request: ChatRequest) → ChatResponse
create_embedding(input: str) → Embedding
call_function(name: str, args: dict) → dict
1. All direct openai.* calls are moved into OpenAiService : IAiService.
2. reginaldCog only interacts with IAiService and no longer imports openai.
3. Configuration allows switching providers without code changes.
4. A mock IAiService is available and used in unit tests to simulate responses.
5. Bot behavior remains unchanged when using OpenAiService.
## Definition of Done
- [ ] Code reviewed, demo'ed & accepted before merge
- [ ] Code merged
- [ ] Docs updated
AllfatherHatt
added this to the Reginald Camp project 2025-06-14 15:43:07 +02:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
User Story
As a developer, I want the Cog’s AI-calling logic to depend on an abstract interface rather than directly on OpenAI, so that we can swap in other AI providers (Anthropic, Azure, local LLM, etc.) without touching the core code.
Description
Acceptance Criteria
An IAiService interface exists with methods for:
All direct openai.* calls are moved into OpenAiService : IAiService.
reginaldCog only interacts with IAiService and no longer imports openai.
Configuration allows switching providers without code changes.
A mock IAiService is available and used in unit tests to simulate responses.
Bot behavior remains unchanged when using OpenAiService.
Definition of Done