Adds "Elsa.OpenAI" capabilities#98
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds OpenAI integration capabilities to the Elsa Workflows framework, enabling GPT-based text generation and chatbot functionality within workflow definitions. The implementation provides a complete OpenAI module with client factory services, base activity classes, and a concrete chat completion activity, along with comprehensive unit and integration tests.
Key Changes
- Implements
OpenAIClientFactoryservice with thread-safe client caching for efficient API key management - Adds
OpenAIActivitybase class andCompleteChatactivity for chat completions with configurable parameters - Introduces comprehensive test suite with unit, integration, and feature tests covering edge cases and concurrency
- Updates build configuration to support multi-targeting (net8.0 and net9.0) and adds necessary package dependencies
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 26 comments.
Show a summary per file
| File | Description |
|---|---|
src/Elsa.OpenAI/Services/OpenAIClientFactory.cs |
Factory service for creating and caching OpenAI API clients with thread-safe operations |
src/Elsa.OpenAI/Activities/OpenAIActivity.cs |
Abstract base class providing common OpenAI client access methods for all activities |
src/Elsa.OpenAI/Activities/Chat/CompleteChat.cs |
Activity implementation for completing chat conversations via OpenAI API |
src/Elsa.OpenAI/Features/OpenAIFeature.cs |
Feature registration class for dependency injection setup |
src/Elsa.OpenAI/README.md |
Comprehensive documentation with usage examples and configuration guide |
test/unit/Elsa.OpenAI.Tests/Services/OpenAIClientFactoryTests.cs |
Extensive unit tests for factory including caching, validation, and concurrency |
test/unit/Elsa.OpenAI.Tests/Integration/OpenAIIntegrationTests.cs |
Integration tests for real API calls and client creation |
test/unit/Elsa.OpenAI.Tests/Features/OpenAIFeatureTests.cs |
Tests for feature registration and service configuration |
test/unit/Elsa.OpenAI.Tests/Activities/OpenAIActivityTests.cs |
Base activity class tests verifying inheritance and method signatures |
test/unit/Elsa.OpenAI.Tests/Activities/Chat/CompleteChatTests.cs |
Comprehensive tests for CompleteChat activity structure and attributes |
test/Directory.Build.props |
Updated test projects to support multi-targeting with conditional package references |
Directory.Packages.props |
Added package version entries for OpenAI SDK, Moq, and configuration packages |
README.md |
Updated integration status to mark OpenAI as completed |
Comments suppressed due to low confidence (2)
src/Elsa.OpenAI/Activities/Chat/CompleteChat.cs:69
- This assignment to maxTokens is useless, since its value is never read.
int? maxTokens = context.Get(MaxTokens);
src/Elsa.OpenAI/Activities/Chat/CompleteChat.cs:70
- This assignment to temperature is useless, since its value is never read.
float? temperature = context.Get(Temperature);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@dotnet-policy-service agree |
fb3a862 to
c744af0
Compare
|
PR author is not in the allowed authors list. |
92bfc24 to
99964de
Compare
|
Hey @sfmskywalker 👋 — this PR has been updated and is ready for review. What changed since the original submission:
Happy to make any adjustments based on your feedback! |
- OpenAI SDK 2.10.0 with thread-safe ConcurrentDictionary-based client factory - Activities: CompleteChat with proper ChatMessage list and ChatCompletionOptions - Module structure follows upstream conventions (src/modules/llm, test/modules/llm) - Comprehensive test suite (67 tests) with parameterized validation coverage - README with complete working examples including ApiKey configuration Co-Authored-By: Oz <oz-agent@warp.dev>
99964de to
200845f
Compare
No description provided.