Skip to content

Adds "Elsa.OpenAI" capabilities#98

Open
Zettersten wants to merge 1 commit into
elsa-workflows:mainfrom
Zettersten:feature/elsa-openai
Open

Adds "Elsa.OpenAI" capabilities#98
Zettersten wants to merge 1 commit into
elsa-workflows:mainfrom
Zettersten:feature/elsa-openai

Conversation

@Zettersten

Copy link
Copy Markdown

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 OpenAIClientFactory service with thread-safe client caching for efficient API key management
  • Adds OpenAIActivity base class and CompleteChat activity 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.

Comment thread src/modules/llm/Elsa.OpenAI/Services/OpenAIClientFactory.cs
Comment thread src/modules/llm/Elsa.OpenAI/README.md
Comment thread src/modules/llm/Elsa.OpenAI/README.md
Comment thread src/modules/llm/Elsa.OpenAI/Services/OpenAIClientFactory.cs
Comment thread src/modules/llm/Elsa.OpenAI/Services/OpenAIClientFactory.cs
Comment thread test/unit/Elsa.OpenAI.Tests/Activities/OpenAIActivityTests.cs Outdated
Comment thread test/unit/Elsa.OpenAI.Tests/Activities/OpenAIActivityTests.cs Outdated
Comment thread test/unit/Elsa.OpenAI.Tests/Activities/OpenAIActivityTests.cs Outdated
Comment thread test/unit/Elsa.OpenAI.Tests/Activities/Chat/CompleteChatTests.cs Outdated
Comment thread test/unit/Elsa.OpenAI.Tests/Integration/OpenAIIntegrationTests.cs Outdated
@Zettersten

Copy link
Copy Markdown
Author

@dotnet-policy-service agree

@sfmskywalker sfmskywalker changed the base branch from main to develop/3.6.0 December 14, 2025 14:47
@sfmskywalker sfmskywalker changed the base branch from develop/3.6.0 to patch/3.5.2 December 14, 2025 14:47
@Zettersten Zettersten force-pushed the feature/elsa-openai branch from fb3a862 to c744af0 Compare May 22, 2026 00:42
@greptile-apps

greptile-apps Bot commented May 22, 2026

Copy link
Copy Markdown

PR author is not in the allowed authors list.

@Zettersten Zettersten changed the base branch from patch/3.5.2 to main May 22, 2026 00:43
@Zettersten Zettersten force-pushed the feature/elsa-openai branch 3 times, most recently from 92bfc24 to 99964de Compare May 22, 2026 03:01
@Zettersten

Copy link
Copy Markdown
Author

Hey @sfmskywalker 👋 — this PR has been updated and is ready for review.

What changed since the original submission:

  • Rebased onto current main — clean single commit, no merge conflicts
  • Bumped OpenAI SDK from 2.7.0 → 2.10.0
  • Moved to module structure — now at src/modules/llm/Elsa.OpenAI and est/modules/llm/Elsa.OpenAI.Tests following upstream conventions
  • Applied .NET best practices — sealed types, ConcurrentDictionary for thread-safe client caching, ArgumentException.ThrowIfNullOrWhiteSpace, proper ChatMessage list usage, comprehensive XML docs
  • 67 passing tests with parameterized validation coverage
  • Fixed README examples — all CompleteChat instances now include the required ApiKey property

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>
@Zettersten Zettersten force-pushed the feature/elsa-openai branch from 99964de to 200845f Compare May 22, 2026 03:08
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.

3 participants