langfuse-ruby 0.1.3 → 0.1.5
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 +4 -4
- data/.github/workflows/ci.yml +53 -0
- data/CHANGELOG.md +45 -4
- data/Gemfile.lock +7 -3
- data/README.md +11 -2
- data/docs/URL_ENCODING_FIX.md +164 -0
- data/examples/basic_tracing.rb +1 -1
- data/examples/url_encoding_demo.rb +57 -0
- data/langfuse-ruby.gemspec +7 -4
- data/lib/langfuse/client.rb +184 -4
- data/lib/langfuse/event.rb +21 -5
- data/lib/langfuse/generation.rb +155 -5
- data/lib/langfuse/observation_types.rb +61 -0
- data/lib/langfuse/span.rb +162 -7
- data/lib/langfuse/trace.rb +185 -1
- data/lib/langfuse/utils.rb +5 -0
- data/lib/langfuse/version.rb +1 -1
- data/lib/langfuse.rb +1 -0
- data/test_offline.rb +33 -7
- metadata +39 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 35c5fecfa9511702e3119b58f09de37402f8fdefa118a8f848b4e64a439a383c
|
|
4
|
+
data.tar.gz: 0057c42d68a7f170f5118efc9378b751d627ef51a11fc87ec965d60be049645b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ee91c309e962d21351e33a3683602b873d167038d90488e0460677959d7c32ad3f715bd77672d3fd6f7f0e21601370fc75fbd6aa2562add32e54b7ae14e79912
|
|
7
|
+
data.tar.gz: f336046b47e535cf36c0f562bb012e419801300aff98acc49e9ee13aebb037d65785c21491a41f6f0cc3cda92ba839bebfa9cbf248e83fa4451939573ca139ec
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main, master ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main, master ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
ruby-version: ['3.1', '3.2', '3.3']
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
|
21
|
+
uses: ruby/setup-ruby@v1
|
|
22
|
+
with:
|
|
23
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
24
|
+
bundler-cache: true
|
|
25
|
+
|
|
26
|
+
- name: Run tests
|
|
27
|
+
run: bundle exec rspec
|
|
28
|
+
|
|
29
|
+
- name: Run offline tests
|
|
30
|
+
run: bundle exec ruby test_offline.rb
|
|
31
|
+
|
|
32
|
+
- name: Run RuboCop
|
|
33
|
+
run: bundle exec rubocop
|
|
34
|
+
continue-on-error: true
|
|
35
|
+
|
|
36
|
+
build:
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
needs: test
|
|
39
|
+
|
|
40
|
+
steps:
|
|
41
|
+
- uses: actions/checkout@v4
|
|
42
|
+
|
|
43
|
+
- name: Set up Ruby
|
|
44
|
+
uses: ruby/setup-ruby@v1
|
|
45
|
+
with:
|
|
46
|
+
ruby-version: '3.2'
|
|
47
|
+
bundler-cache: true
|
|
48
|
+
|
|
49
|
+
- name: Build gem
|
|
50
|
+
run: gem build langfuse-ruby.gemspec
|
|
51
|
+
|
|
52
|
+
- name: Verify gem can be installed
|
|
53
|
+
run: gem install langfuse-ruby-*.gem
|
data/CHANGELOG.md
CHANGED
|
@@ -7,20 +7,61 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.1.5] - 2025-12-26
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Support for all enhanced observation types: `agent`, `tool`, `chain`, `retriever`, `embedding`, `evaluator`, `guardrail`
|
|
14
|
+
- New `ObservationType` module with constants for all observation types
|
|
15
|
+
- Convenience methods on `Client` and `Trace` for creating enhanced observations
|
|
16
|
+
- New `as_type` parameter on `span()` method for specifying observation type
|
|
17
|
+
- Comprehensive test coverage for enhanced observation types
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
- Fixed URL encoding for prompt names containing special characters (/, spaces, etc.) in `get_prompt` method
|
|
21
|
+
- Prompt names are now automatically URL-encoded before being interpolated into API paths
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
- Updated Ruby version requirement to >= 3.1.0
|
|
25
|
+
- Environment variables moved from metadata to top-level trace attributes
|
|
26
|
+
|
|
27
|
+
### Internal
|
|
28
|
+
- Added `Utils.url_encode` helper method for consistent URL encoding across the SDK
|
|
29
|
+
- CI improvements for offline test execution
|
|
30
|
+
|
|
31
|
+
## [0.1.4] - 2025-07-29
|
|
32
|
+
|
|
10
33
|
### Added
|
|
34
|
+
- Added support for `trace-update` event type in Langfuse ingestion API
|
|
11
35
|
- Added support for `event-create` event type in Langfuse ingestion API
|
|
12
36
|
- New `Event` class for creating generic events within traces, spans, and generations
|
|
13
37
|
- Added `event()` method to `Client`, `Trace`, `Span`, and `Generation` classes
|
|
14
38
|
- Enhanced event validation to include all supported Langfuse event types
|
|
15
39
|
- New example file `examples/event_usage.rb` demonstrating event functionality
|
|
16
40
|
|
|
17
|
-
|
|
41
|
+
### Fixed
|
|
42
|
+
- Improved offline test error handling and authentication validation
|
|
43
|
+
- Enhanced error handling tests with proper configuration management
|
|
44
|
+
- Fixed prompt template validation tests in offline mode
|
|
45
|
+
- Better error message handling for authentication failures
|
|
18
46
|
|
|
19
|
-
###
|
|
47
|
+
### Improved
|
|
48
|
+
- More comprehensive error handling test coverage
|
|
49
|
+
- Better test isolation and cleanup procedures
|
|
50
|
+
- Enhanced debugging capabilities for offline testing
|
|
51
|
+
|
|
52
|
+
## [0.1.3] - 2025-07-13
|
|
53
|
+
|
|
54
|
+
### Fixed
|
|
55
|
+
- Enhanced event data validation and debugging capabilities
|
|
56
|
+
- More detailed error messages for event structure validation failures
|
|
57
|
+
|
|
58
|
+
## [0.1.2] - 2025-07-12
|
|
59
|
+
|
|
60
|
+
### Fixed
|
|
20
61
|
- Enhanced event data validation and debugging capabilities
|
|
21
62
|
- More detailed error messages for event structure validation failures
|
|
22
63
|
|
|
23
|
-
## [0.1.1] - 2025-
|
|
64
|
+
## [0.1.1] - 2025-07-12
|
|
24
65
|
|
|
25
66
|
### Fixed
|
|
26
67
|
- Improved error handling for `get_prompt` method when prompt doesn't exist
|
|
@@ -36,7 +77,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
36
77
|
- Updated gemspec metadata to avoid RubyGems warnings
|
|
37
78
|
- Improved documentation with clearer error handling examples
|
|
38
79
|
|
|
39
|
-
## [0.1.0] - 2025-
|
|
80
|
+
## [0.1.0] - 2025-07-12
|
|
40
81
|
|
|
41
82
|
### Added
|
|
42
83
|
- Initial release of Langfuse Ruby SDK
|
data/Gemfile.lock
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
langfuse-ruby (0.1.
|
|
4
|
+
langfuse-ruby (0.1.5)
|
|
5
5
|
concurrent-ruby (~> 1.0)
|
|
6
|
-
faraday (
|
|
7
|
-
faraday-
|
|
6
|
+
faraday (>= 1.8, < 3.0)
|
|
7
|
+
faraday-multipart (~> 1.0)
|
|
8
|
+
faraday-net_http (>= 1.0, < 4.0)
|
|
8
9
|
json (~> 2.0)
|
|
9
10
|
|
|
10
11
|
GEM
|
|
@@ -24,6 +25,8 @@ GEM
|
|
|
24
25
|
faraday-net_http (>= 2.0, < 3.5)
|
|
25
26
|
json
|
|
26
27
|
logger
|
|
28
|
+
faraday-multipart (1.1.1)
|
|
29
|
+
multipart-post (~> 2.0)
|
|
27
30
|
faraday-net_http (3.4.1)
|
|
28
31
|
net-http (>= 0.5.0)
|
|
29
32
|
hashdiff (1.2.0)
|
|
@@ -31,6 +34,7 @@ GEM
|
|
|
31
34
|
language_server-protocol (3.17.0.5)
|
|
32
35
|
lint_roller (1.1.0)
|
|
33
36
|
logger (1.7.0)
|
|
37
|
+
multipart-post (2.4.1)
|
|
34
38
|
net-http (0.6.0)
|
|
35
39
|
uri
|
|
36
40
|
parallel (1.27.0)
|
data/README.md
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# Langfuse Ruby SDK
|
|
2
2
|
|
|
3
3
|
[](https://badge.fury.io/rb/langfuse-ruby)
|
|
4
|
-
[](https://github.com/ai-firstly/langfuse-ruby/actions/workflows/ci.yml)
|
|
5
|
+
[](https://www.ruby-lang.org/)
|
|
6
|
+
[](LICENSE)
|
|
5
7
|
|
|
6
8
|
Ruby SDK for [Langfuse](https://langfuse.com) - the open-source LLM engineering platform. This SDK provides comprehensive tracing, prompt management, and evaluation capabilities for LLM applications.
|
|
7
9
|
|
|
@@ -67,7 +69,7 @@ trace = client.trace(
|
|
|
67
69
|
name: "chat-completion",
|
|
68
70
|
user_id: "user123",
|
|
69
71
|
session_id: "session456",
|
|
70
|
-
|
|
72
|
+
environment: "production"
|
|
71
73
|
)
|
|
72
74
|
|
|
73
75
|
# Add a generation (LLM call)
|
|
@@ -80,6 +82,8 @@ generation = trace.generation(
|
|
|
80
82
|
|
|
81
83
|
generation.end(output: 'Hello! How can I help you today?', usage: { prompt_tokens: 10, completion_tokens: 15, total_tokens: 25 })
|
|
82
84
|
|
|
85
|
+
trace.update(output: 'Hello! How can I help you today?')
|
|
86
|
+
|
|
83
87
|
# Flush events (optional - happens automatically)
|
|
84
88
|
client.flush
|
|
85
89
|
```
|
|
@@ -169,6 +173,9 @@ event = client.event(
|
|
|
169
173
|
# Get a prompt
|
|
170
174
|
prompt = client.get_prompt("chat-prompt", version: 1)
|
|
171
175
|
|
|
176
|
+
# Prompt names with special characters are automatically URL-encoded
|
|
177
|
+
prompt = client.get_prompt("EXEMPLE/my-prompt") # Works correctly!
|
|
178
|
+
|
|
172
179
|
# Compile prompt with variables
|
|
173
180
|
compiled = prompt.compile(
|
|
174
181
|
user_name: "Alice",
|
|
@@ -179,6 +186,8 @@ puts compiled
|
|
|
179
186
|
# Output: "Hello Alice! Let's discuss machine learning today."
|
|
180
187
|
```
|
|
181
188
|
|
|
189
|
+
> **Note**: Prompt names containing special characters (like `/`, spaces, `?`, etc.) are automatically URL-encoded. You don't need to manually encode them.
|
|
190
|
+
|
|
182
191
|
### Create Prompts
|
|
183
192
|
|
|
184
193
|
```ruby
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# URL Encoding Fix for Prompt Names
|
|
2
|
+
|
|
3
|
+
## Issue Summary
|
|
4
|
+
|
|
5
|
+
**Issue ID**: AIF-2
|
|
6
|
+
**Title**: Prompt names with `/` are not URL-encoded
|
|
7
|
+
**Status**: Fixed
|
|
8
|
+
|
|
9
|
+
## Problem Description
|
|
10
|
+
|
|
11
|
+
Prompt names containing special characters (particularly `/`) were not being URL-encoded before being interpolated into the API path when using `get_prompt`. This caused the server to misinterpret the prompt name as a nested path structure, resulting in 404 errors.
|
|
12
|
+
|
|
13
|
+
### Example
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
# Before fix
|
|
17
|
+
client.get_prompt("EXEMPLE/my-prompt")
|
|
18
|
+
|
|
19
|
+
# Generated URL (broken):
|
|
20
|
+
# /api/public/v2/prompts/EXEMPLE/my-prompt
|
|
21
|
+
# Server interprets this as: /api/public/v2/prompts/EXEMPLE/<nested-path>/my-prompt
|
|
22
|
+
# Result: 404 Not Found
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Expected Behavior
|
|
26
|
+
|
|
27
|
+
```ruby
|
|
28
|
+
# After fix
|
|
29
|
+
client.get_prompt("EXEMPLE/my-prompt")
|
|
30
|
+
|
|
31
|
+
# Generated URL (correct):
|
|
32
|
+
# /api/public/v2/prompts/EXEMPLE%2Fmy-prompt
|
|
33
|
+
# Server correctly interprets this as a single prompt name
|
|
34
|
+
# Result: Prompt found successfully
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Solution
|
|
38
|
+
|
|
39
|
+
### Changes Made
|
|
40
|
+
|
|
41
|
+
1. **Added URL encoding utility** (`lib/langfuse/utils.rb`):
|
|
42
|
+
- Added `Utils.url_encode` method using Ruby's `ERB::Util.url_encode`
|
|
43
|
+
- Provides consistent URL encoding across the SDK
|
|
44
|
+
|
|
45
|
+
2. **Updated `get_prompt` method** (`lib/langfuse/client.rb`):
|
|
46
|
+
- Automatically URL-encodes prompt names before constructing API paths
|
|
47
|
+
- No breaking changes - existing code continues to work
|
|
48
|
+
|
|
49
|
+
3. **Added comprehensive tests** (`spec/langfuse/client_spec.rb`):
|
|
50
|
+
- Tests for forward slashes in prompt names
|
|
51
|
+
- Tests for spaces in prompt names
|
|
52
|
+
- Tests for multiple special characters
|
|
53
|
+
- Tests for simple names (no encoding needed)
|
|
54
|
+
|
|
55
|
+
4. **Updated documentation**:
|
|
56
|
+
- Added note in README about automatic URL encoding
|
|
57
|
+
- Added example demonstrating the feature
|
|
58
|
+
- Updated CHANGELOG with fix details
|
|
59
|
+
|
|
60
|
+
### Code Changes
|
|
61
|
+
|
|
62
|
+
#### lib/langfuse/utils.rb
|
|
63
|
+
```ruby
|
|
64
|
+
def url_encode(string)
|
|
65
|
+
ERB::Util.url_encode(string.to_s)
|
|
66
|
+
end
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### lib/langfuse/client.rb
|
|
70
|
+
```ruby
|
|
71
|
+
def get_prompt(name, version: nil, label: nil, cache_ttl_seconds: 60)
|
|
72
|
+
# ... existing code ...
|
|
73
|
+
|
|
74
|
+
encoded_name = Utils.url_encode(name)
|
|
75
|
+
path = "/api/public/v2/prompts/#{encoded_name}"
|
|
76
|
+
|
|
77
|
+
# ... rest of method ...
|
|
78
|
+
end
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Testing
|
|
82
|
+
|
|
83
|
+
### Test Coverage
|
|
84
|
+
|
|
85
|
+
All test cases pass successfully:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
$ bundle exec rspec spec/langfuse/client_spec.rb -e "get_prompt"
|
|
89
|
+
|
|
90
|
+
Langfuse::Client
|
|
91
|
+
#get_prompt
|
|
92
|
+
URL-encodes prompt names with special characters ✓
|
|
93
|
+
URL-encodes prompt names with spaces ✓
|
|
94
|
+
URL-encodes prompt names with multiple special characters ✓
|
|
95
|
+
handles simple prompt names without special characters ✓
|
|
96
|
+
|
|
97
|
+
4 examples, 0 failures
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Test Cases
|
|
101
|
+
|
|
102
|
+
1. **Forward slash**: `EXEMPLE/my-prompt` → `EXEMPLE%2Fmy-prompt`
|
|
103
|
+
2. **Spaces**: `my prompt` → `my%20prompt`
|
|
104
|
+
3. **Multiple special chars**: `test/prompt name?query` → `test%2Fprompt%20name%3Fquery`
|
|
105
|
+
4. **Simple names**: `simple-prompt` → `simple-prompt` (no encoding needed)
|
|
106
|
+
|
|
107
|
+
## Usage
|
|
108
|
+
|
|
109
|
+
### Before Fix (Workaround)
|
|
110
|
+
|
|
111
|
+
Users had to manually encode prompt names:
|
|
112
|
+
|
|
113
|
+
```ruby
|
|
114
|
+
encoded_name = ERB::Util.url_encode("EXEMPLE/my-prompt")
|
|
115
|
+
client.get_prompt(encoded_name)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### After Fix (Automatic)
|
|
119
|
+
|
|
120
|
+
Users can now use prompt names directly:
|
|
121
|
+
|
|
122
|
+
```ruby
|
|
123
|
+
# Works automatically!
|
|
124
|
+
client.get_prompt("EXEMPLE/my-prompt")
|
|
125
|
+
client.get_prompt("my prompt name")
|
|
126
|
+
client.get_prompt("test/prompt?query")
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Backward Compatibility
|
|
130
|
+
|
|
131
|
+
This fix is **100% backward compatible**:
|
|
132
|
+
|
|
133
|
+
- Existing code continues to work without changes
|
|
134
|
+
- Simple prompt names (without special characters) work exactly as before
|
|
135
|
+
- If users were manually encoding names, double-encoding is prevented by the URL encoding algorithm
|
|
136
|
+
|
|
137
|
+
## Special Characters Supported
|
|
138
|
+
|
|
139
|
+
The following special characters are now properly encoded:
|
|
140
|
+
|
|
141
|
+
- `/` (forward slash) → `%2F`
|
|
142
|
+
- ` ` (space) → `%20`
|
|
143
|
+
- `?` (question mark) → `%3F`
|
|
144
|
+
- `#` (hash) → `%23`
|
|
145
|
+
- `@` (at sign) → `%40`
|
|
146
|
+
- `&` (ampersand) → `%26`
|
|
147
|
+
- `=` (equals) → `%3D`
|
|
148
|
+
- `+` (plus) → `%2B`
|
|
149
|
+
- And all other URL-unsafe characters
|
|
150
|
+
|
|
151
|
+
## Related Files
|
|
152
|
+
|
|
153
|
+
- `lib/langfuse/utils.rb` - URL encoding utility
|
|
154
|
+
- `lib/langfuse/client.rb` - Updated `get_prompt` method
|
|
155
|
+
- `spec/langfuse/client_spec.rb` - Test coverage
|
|
156
|
+
- `examples/url_encoding_demo.rb` - Usage examples
|
|
157
|
+
- `CHANGELOG.md` - Change documentation
|
|
158
|
+
- `README.md` - Updated documentation
|
|
159
|
+
|
|
160
|
+
## References
|
|
161
|
+
|
|
162
|
+
- Linear Issue: AIF-2
|
|
163
|
+
- Ruby ERB::Util documentation: https://ruby-doc.org/stdlib-3.0.0/libdoc/erb/rdoc/ERB/Util.html
|
|
164
|
+
- URL encoding standard: RFC 3986
|
data/examples/basic_tracing.rb
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# This example demonstrates URL encoding for prompt names with special characters
|
|
5
|
+
# such as forward slashes, spaces, and other URL-unsafe characters.
|
|
6
|
+
|
|
7
|
+
require_relative '../lib/langfuse'
|
|
8
|
+
|
|
9
|
+
# Initialize the Langfuse client
|
|
10
|
+
client = Langfuse::Client.new(
|
|
11
|
+
public_key: ENV['LANGFUSE_PUBLIC_KEY'] || 'your-public-key',
|
|
12
|
+
secret_key: ENV['LANGFUSE_SECRET_KEY'] || 'your-secret-key',
|
|
13
|
+
host: ENV['LANGFUSE_HOST'] || 'https://cloud.langfuse.com'
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
# Example 1: Prompt name with forward slash
|
|
17
|
+
# Before fix: Would result in 404 error
|
|
18
|
+
# After fix: Automatically URL-encoded to EXEMPLE%2Fmy-prompt
|
|
19
|
+
puts 'Example 1: Fetching prompt with forward slash in name'
|
|
20
|
+
begin
|
|
21
|
+
prompt = client.get_prompt('EXEMPLE/my-prompt')
|
|
22
|
+
puts "✓ Successfully fetched prompt: #{prompt.name}"
|
|
23
|
+
rescue Langfuse::ValidationError => e
|
|
24
|
+
puts "✗ Error: #{e.message}"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Example 2: Prompt name with spaces
|
|
28
|
+
puts "\nExample 2: Fetching prompt with spaces in name"
|
|
29
|
+
begin
|
|
30
|
+
prompt = client.get_prompt('my prompt name')
|
|
31
|
+
puts "✓ Successfully fetched prompt: #{prompt.name}"
|
|
32
|
+
rescue Langfuse::ValidationError => e
|
|
33
|
+
puts "✗ Error: #{e.message}"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Example 3: Prompt name with multiple special characters
|
|
37
|
+
puts "\nExample 3: Fetching prompt with multiple special characters"
|
|
38
|
+
begin
|
|
39
|
+
prompt = client.get_prompt('test/prompt name?query')
|
|
40
|
+
puts "✓ Successfully fetched prompt: #{prompt.name}"
|
|
41
|
+
rescue Langfuse::ValidationError => e
|
|
42
|
+
puts "✗ Error: #{e.message}"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Example 4: Simple prompt name (no special characters)
|
|
46
|
+
puts "\nExample 4: Fetching prompt with simple name"
|
|
47
|
+
begin
|
|
48
|
+
prompt = client.get_prompt('simple-prompt')
|
|
49
|
+
puts "✓ Successfully fetched prompt: #{prompt.name}"
|
|
50
|
+
rescue Langfuse::ValidationError => e
|
|
51
|
+
puts "✗ Error: #{e.message}"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
puts "\n" + '=' * 60
|
|
55
|
+
puts 'Note: The client now automatically URL-encodes prompt names.'
|
|
56
|
+
puts 'You no longer need to manually encode them!'
|
|
57
|
+
puts '=' * 60
|
data/langfuse-ruby.gemspec
CHANGED
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
|
12
12
|
'and evaluation capabilities for LLM applications'
|
|
13
13
|
spec.homepage = 'https://langfuse.com'
|
|
14
14
|
spec.license = 'MIT'
|
|
15
|
-
spec.required_ruby_version = '>=
|
|
15
|
+
spec.required_ruby_version = '>= 3.1.0'
|
|
16
16
|
|
|
17
17
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
|
18
18
|
spec.metadata['homepage_uri'] = 'https://langfuse.com/docs/sdk/ruby'
|
|
@@ -24,7 +24,9 @@ Gem::Specification.new do |spec|
|
|
|
24
24
|
# Specify which files should be added to the gem when it is released.
|
|
25
25
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
26
26
|
if File.exist?('.git')
|
|
27
|
-
`git ls-files -z`.split("\x0").reject
|
|
27
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
28
|
+
(f == 'ISSUE_AIF-2_RESOLUTION.md') || f.match(%r{\A(?:test|spec|features)/})
|
|
29
|
+
end
|
|
28
30
|
else
|
|
29
31
|
Dir.glob('**/*').reject do |f|
|
|
30
32
|
File.directory?(f) ||
|
|
@@ -41,8 +43,9 @@ Gem::Specification.new do |spec|
|
|
|
41
43
|
|
|
42
44
|
# Dependencies
|
|
43
45
|
spec.add_dependency 'concurrent-ruby', '~> 1.0'
|
|
44
|
-
spec.add_dependency 'faraday', '
|
|
45
|
-
spec.add_dependency 'faraday-net_http', '
|
|
46
|
+
spec.add_dependency 'faraday', '>= 1.8', '< 3.0'
|
|
47
|
+
spec.add_dependency 'faraday-net_http', '>= 1.0', '< 4.0'
|
|
48
|
+
spec.add_dependency 'faraday-multipart', '~> 1.0'
|
|
46
49
|
spec.add_dependency 'json', '~> 2.0'
|
|
47
50
|
|
|
48
51
|
# Development dependencies
|