rack-ai 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +55 -0
- data/CHANGELOG.md +65 -0
- data/LICENSE +21 -0
- data/README.md +687 -0
- data/ROADMAP.md +203 -0
- data/Rakefile +40 -0
- data/benchmarks/performance_benchmark.rb +283 -0
- data/examples/rails_integration.rb +301 -0
- data/examples/sinatra_integration.rb +458 -0
- data/lib/rack/ai/configuration.rb +208 -0
- data/lib/rack/ai/features/caching.rb +278 -0
- data/lib/rack/ai/features/classification.rb +67 -0
- data/lib/rack/ai/features/enhancement.rb +219 -0
- data/lib/rack/ai/features/logging.rb +238 -0
- data/lib/rack/ai/features/moderation.rb +104 -0
- data/lib/rack/ai/features/routing.rb +143 -0
- data/lib/rack/ai/features/security.rb +275 -0
- data/lib/rack/ai/middleware.rb +268 -0
- data/lib/rack/ai/providers/base.rb +107 -0
- data/lib/rack/ai/providers/huggingface.rb +259 -0
- data/lib/rack/ai/providers/local.rb +152 -0
- data/lib/rack/ai/providers/openai.rb +246 -0
- data/lib/rack/ai/utils/logger.rb +111 -0
- data/lib/rack/ai/utils/metrics.rb +220 -0
- data/lib/rack/ai/utils/sanitizer.rb +200 -0
- data/lib/rack/ai/version.rb +7 -0
- data/lib/rack/ai.rb +48 -0
- data/rack-ai.gemspec +51 -0
- metadata +290 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5c647f66a3eae25ff6af97c25cbb4dcee2a5fc55c959e04f8b441e40e01c3622
|
4
|
+
data.tar.gz: 485eebfb792effaa6ea9ae8878f3a81e06cb4520728c7df55b81817254bc0cd7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f1aef3c9f81e822afb3e140063bb919d33c0bacf1a3ac988e6e8a236292d8f1c0b2fb8ca642d25ea6ab4864b4cd79dffbc49b1c67bfbd5c4d9b7e4d4145f3670
|
7
|
+
data.tar.gz: 10de1bd82c8ca26da97490da3bd13bff8b7cdf5a2a52107507d81c674b926aae7f3bbbbf75cc0631b73f874147492b8e20ff9f44578ce7c777a133a4366891d1
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rspec
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
TargetRubyVersion: 3.0
|
6
|
+
NewCops: enable
|
7
|
+
Exclude:
|
8
|
+
- 'vendor/**/*'
|
9
|
+
- 'tmp/**/*'
|
10
|
+
- 'bin/**/*'
|
11
|
+
|
12
|
+
# Layout
|
13
|
+
Layout/LineLength:
|
14
|
+
Max: 120
|
15
|
+
Exclude:
|
16
|
+
- 'spec/**/*'
|
17
|
+
|
18
|
+
# Style
|
19
|
+
Style/Documentation:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Style/StringLiterals:
|
23
|
+
EnforcedStyle: double_quotes
|
24
|
+
|
25
|
+
Style/FrozenStringLiteralComment:
|
26
|
+
Enabled: true
|
27
|
+
|
28
|
+
# Metrics
|
29
|
+
Metrics/BlockLength:
|
30
|
+
Exclude:
|
31
|
+
- 'spec/**/*'
|
32
|
+
- 'examples/**/*'
|
33
|
+
- 'benchmarks/**/*'
|
34
|
+
|
35
|
+
Metrics/ModuleLength:
|
36
|
+
Exclude:
|
37
|
+
- 'spec/**/*'
|
38
|
+
|
39
|
+
Metrics/ClassLength:
|
40
|
+
Max: 200
|
41
|
+
|
42
|
+
Metrics/MethodLength:
|
43
|
+
Max: 30
|
44
|
+
Exclude:
|
45
|
+
- 'spec/**/*'
|
46
|
+
|
47
|
+
# RSpec
|
48
|
+
RSpec/ExampleLength:
|
49
|
+
Max: 20
|
50
|
+
|
51
|
+
RSpec/MultipleExpectations:
|
52
|
+
Max: 5
|
53
|
+
|
54
|
+
RSpec/NestedGroups:
|
55
|
+
Max: 4
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
## [0.1.0] - 2024-09-11
|
11
|
+
|
12
|
+
### Added
|
13
|
+
- Initial release of Rack::AI middleware
|
14
|
+
- Core AI-powered features:
|
15
|
+
- Request classification (human, bot, spam, suspicious)
|
16
|
+
- Content moderation with toxicity detection
|
17
|
+
- Security analysis and threat detection
|
18
|
+
- Smart caching with predictive capabilities
|
19
|
+
- Intelligent routing based on AI analysis
|
20
|
+
- Enhanced logging with AI insights
|
21
|
+
- Content enhancement (SEO, readability, accessibility)
|
22
|
+
- Multi-provider support:
|
23
|
+
- OpenAI integration
|
24
|
+
- HuggingFace integration
|
25
|
+
- Local AI model support
|
26
|
+
- Comprehensive configuration system:
|
27
|
+
- Ruby DSL configuration
|
28
|
+
- Environment-specific settings
|
29
|
+
- Feature toggles and thresholds
|
30
|
+
- Production-ready features:
|
31
|
+
- Fail-safe mode for reliability
|
32
|
+
- Async processing for performance
|
33
|
+
- Data sanitization for security
|
34
|
+
- Comprehensive error handling
|
35
|
+
- Framework integrations:
|
36
|
+
- Rails middleware integration
|
37
|
+
- Sinatra application examples
|
38
|
+
- Custom Rack application support
|
39
|
+
- Monitoring and observability:
|
40
|
+
- Built-in metrics collection
|
41
|
+
- Prometheus format export
|
42
|
+
- Structured logging
|
43
|
+
- Performance benchmarks
|
44
|
+
- Developer experience:
|
45
|
+
- Comprehensive test suite
|
46
|
+
- Performance benchmarks
|
47
|
+
- Detailed documentation
|
48
|
+
- Integration examples
|
49
|
+
|
50
|
+
### Security
|
51
|
+
- Data sanitization to prevent sensitive information leakage
|
52
|
+
- Security-first design with configurable data types
|
53
|
+
- Rate limiting and anomaly detection
|
54
|
+
- SQL injection and XSS detection
|
55
|
+
- Prompt injection protection for LLM endpoints
|
56
|
+
|
57
|
+
### Performance
|
58
|
+
- Async processing support
|
59
|
+
- Connection pooling for AI providers
|
60
|
+
- Redis-based caching
|
61
|
+
- Configurable timeouts and retries
|
62
|
+
- Memory-efficient request processing
|
63
|
+
|
64
|
+
[Unreleased]: https://github.com/ahmetxhero/rack-ai/compare/v0.1.0...HEAD
|
65
|
+
[0.1.0]: https://github.com/ahmetxhero/rack-ai/releases/tag/v0.1.0
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 Ahmet KAHRAMAN (@ahmetxhero)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|