Add OpenAI API Compatibility
-
Task 34: Add OpenAI API Compatibility
- Subtask 1: Create Failing Test for OpenAI Integration
- Create a new test file
src/morpheum-bot/openai.test.ts. - Write a test that attempts to send a prompt to a mock OpenAI server and asserts that a valid response is received. This test should fail initially as the implementation won’t exist.
- Create a new test file
- Subtask 2: Implement OpenAI API Client
- Create a new file
src/morpheum-bot/openai.ts. - Implement a function that takes a prompt and an OpenAI API key and sends a request to the OpenAI API.
- This function should handle the response and return it in a structured format.
- Create
OpenAIClientclass implementingLLMClientinterface. - Support custom base URLs for OpenAI-compatible APIs.
- Create a new file
- Subtask 3: Integrate OpenAI Client into Bot
- Enhanced
src/morpheum-bot/bot.tsto support both OpenAI and Ollama APIs. - Added new commands:
!openai,!ollama,!llm status,!llm switch. - Created comprehensive test suite covering all new functionality.
- Added common
LLMClientinterface and factory pattern. - Updated
SWEAgentto use genericLLMClientinterface. - All tests pass for new integration functionality.
- Enhanced
- Subtask 1: Create Failing Test for OpenAI Integration
Morpheum