langfuse-ruby 0.1.0 → 0.1.2
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/CHANGELOG.md +29 -34
- data/Gemfile +5 -5
- data/Gemfile.lock +1 -1
- data/README.md +3 -3
- data/{PUBLISH_GUIDE.md → docs/PUBLISH_GUIDE.md} +7 -7
- data/docs/README.md +29 -0
- data/examples/connection_config_demo.rb +127 -0
- data/examples/prompt_management.rb +62 -71
- data/langfuse-ruby.gemspec +12 -7
- data/lib/langfuse/client.rb +57 -18
- data/lib/langfuse/evaluation.rb +9 -8
- data/lib/langfuse/prompt.rb +2 -2
- data/lib/langfuse/version.rb +1 -1
- data/lib/langfuse.rb +14 -10
- data/scripts/release.sh +2 -2
- data/scripts/verify_release.rb +2 -2
- metadata +14 -12
- data/PROJECT_SUMMARY.md +0 -263
- data/test_basic.rb +0 -183
- /data/{FINAL_SUMMARY.md → docs/FINAL_SUMMARY.md} +0 -0
- /data/{RELEASE_CHECKLIST.md → docs/RELEASE_CHECKLIST.md} +0 -0
data/test_basic.rb
DELETED
@@ -1,183 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require_relative 'lib/langfuse'
|
4
|
-
|
5
|
-
puts "🚀 Testing Langfuse Ruby SDK..."
|
6
|
-
|
7
|
-
# Test 1: Basic configuration
|
8
|
-
puts "\n1. Testing configuration..."
|
9
|
-
Langfuse.configure do |config|
|
10
|
-
config.public_key = "test_key"
|
11
|
-
config.secret_key = "test_secret"
|
12
|
-
config.host = "https://test.langfuse.com"
|
13
|
-
config.debug = true
|
14
|
-
end
|
15
|
-
|
16
|
-
puts "✅ Configuration successful"
|
17
|
-
puts " Public key: #{Langfuse.configuration.public_key}"
|
18
|
-
puts " Host: #{Langfuse.configuration.host}"
|
19
|
-
|
20
|
-
# Test 2: Client initialization
|
21
|
-
puts "\n2. Testing client initialization..."
|
22
|
-
begin
|
23
|
-
client = Langfuse.new(
|
24
|
-
public_key: "test_key",
|
25
|
-
secret_key: "test_secret",
|
26
|
-
host: "https://test.langfuse.com"
|
27
|
-
)
|
28
|
-
puts "✅ Client initialization successful"
|
29
|
-
puts " Client class: #{client.class}"
|
30
|
-
puts " Public key: #{client.public_key}"
|
31
|
-
rescue => e
|
32
|
-
puts "❌ Client initialization failed: #{e.message}"
|
33
|
-
end
|
34
|
-
|
35
|
-
# Test 3: Trace creation
|
36
|
-
puts "\n3. Testing trace creation..."
|
37
|
-
begin
|
38
|
-
trace = client.trace(
|
39
|
-
name: "test-trace",
|
40
|
-
user_id: "test-user",
|
41
|
-
input: { message: "Hello, world!" }
|
42
|
-
)
|
43
|
-
puts "✅ Trace creation successful"
|
44
|
-
puts " Trace ID: #{trace.id}"
|
45
|
-
puts " Trace name: #{trace.name}"
|
46
|
-
rescue => e
|
47
|
-
puts "❌ Trace creation failed: #{e.message}"
|
48
|
-
end
|
49
|
-
|
50
|
-
# Test 4: Generation creation
|
51
|
-
puts "\n4. Testing generation creation..."
|
52
|
-
begin
|
53
|
-
generation = trace.generation(
|
54
|
-
name: "test-generation",
|
55
|
-
model: "gpt-3.5-turbo",
|
56
|
-
input: [{ role: "user", content: "Hello!" }],
|
57
|
-
output: { content: "Hi there!" }
|
58
|
-
)
|
59
|
-
puts "✅ Generation creation successful"
|
60
|
-
puts " Generation ID: #{generation.id}"
|
61
|
-
puts " Model: #{generation.model}"
|
62
|
-
rescue => e
|
63
|
-
puts "❌ Generation creation failed: #{e.message}"
|
64
|
-
end
|
65
|
-
|
66
|
-
# Test 5: Span creation
|
67
|
-
puts "\n5. Testing span creation..."
|
68
|
-
begin
|
69
|
-
span = trace.span(
|
70
|
-
name: "test-span",
|
71
|
-
input: { query: "test query" }
|
72
|
-
)
|
73
|
-
puts "✅ Span creation successful"
|
74
|
-
puts " Span ID: #{span.id}"
|
75
|
-
puts " Span name: #{span.name}"
|
76
|
-
rescue => e
|
77
|
-
puts "❌ Span creation failed: #{e.message}"
|
78
|
-
end
|
79
|
-
|
80
|
-
# Test 6: Prompt template
|
81
|
-
puts "\n6. Testing prompt template..."
|
82
|
-
begin
|
83
|
-
template = Langfuse::PromptTemplate.from_template(
|
84
|
-
"Hello {{name}}! How are you feeling {{mood}} today?"
|
85
|
-
)
|
86
|
-
|
87
|
-
formatted = template.format(
|
88
|
-
name: "Alice",
|
89
|
-
mood: "happy"
|
90
|
-
)
|
91
|
-
|
92
|
-
puts "✅ Prompt template successful"
|
93
|
-
puts " Template variables: #{template.input_variables}"
|
94
|
-
puts " Formatted: #{formatted}"
|
95
|
-
rescue => e
|
96
|
-
puts "❌ Prompt template failed: #{e.message}"
|
97
|
-
end
|
98
|
-
|
99
|
-
# Test 7: Chat prompt template
|
100
|
-
puts "\n7. Testing chat prompt template..."
|
101
|
-
begin
|
102
|
-
chat_template = Langfuse::ChatPromptTemplate.from_messages([
|
103
|
-
{ role: "system", content: "You are a helpful {{role}} assistant." },
|
104
|
-
{ role: "user", content: "{{user_input}}" }
|
105
|
-
])
|
106
|
-
|
107
|
-
messages = chat_template.format(
|
108
|
-
role: "coding",
|
109
|
-
user_input: "Help me with Ruby"
|
110
|
-
)
|
111
|
-
|
112
|
-
puts "✅ Chat prompt template successful"
|
113
|
-
puts " Template variables: #{chat_template.input_variables}"
|
114
|
-
puts " Messages count: #{messages.length}"
|
115
|
-
rescue => e
|
116
|
-
puts "❌ Chat prompt template failed: #{e.message}"
|
117
|
-
end
|
118
|
-
|
119
|
-
# Test 8: Evaluators
|
120
|
-
puts "\n8. Testing evaluators..."
|
121
|
-
begin
|
122
|
-
# Exact match evaluator
|
123
|
-
exact_match = Langfuse::Evaluators::ExactMatchEvaluator.new
|
124
|
-
result = exact_match.evaluate(
|
125
|
-
input: "What is 2+2?",
|
126
|
-
output: "4",
|
127
|
-
expected: "4"
|
128
|
-
)
|
129
|
-
puts "✅ Exact match evaluator successful"
|
130
|
-
puts " Result: #{result}"
|
131
|
-
|
132
|
-
# Similarity evaluator
|
133
|
-
similarity = Langfuse::Evaluators::SimilarityEvaluator.new
|
134
|
-
result = similarity.evaluate(
|
135
|
-
input: "What is AI?",
|
136
|
-
output: "Artificial Intelligence",
|
137
|
-
expected: "AI is artificial intelligence"
|
138
|
-
)
|
139
|
-
puts "✅ Similarity evaluator successful"
|
140
|
-
puts " Result: #{result}"
|
141
|
-
rescue => e
|
142
|
-
puts "❌ Evaluator failed: #{e.message}"
|
143
|
-
end
|
144
|
-
|
145
|
-
# Test 9: Utils
|
146
|
-
puts "\n9. Testing utilities..."
|
147
|
-
begin
|
148
|
-
id = Langfuse::Utils.generate_id
|
149
|
-
timestamp = Langfuse::Utils.current_timestamp
|
150
|
-
|
151
|
-
puts "✅ Utils successful"
|
152
|
-
puts " Generated ID: #{id}"
|
153
|
-
puts " Timestamp: #{timestamp}"
|
154
|
-
rescue => e
|
155
|
-
puts "❌ Utils failed: #{e.message}"
|
156
|
-
end
|
157
|
-
|
158
|
-
# Test 10: Event queue
|
159
|
-
puts "\n10. Testing event queue..."
|
160
|
-
begin
|
161
|
-
queue_size_before = client.instance_variable_get(:@event_queue).length
|
162
|
-
|
163
|
-
client.score(
|
164
|
-
trace_id: trace.id,
|
165
|
-
name: "test-score",
|
166
|
-
value: 0.9
|
167
|
-
)
|
168
|
-
|
169
|
-
queue_size_after = client.instance_variable_get(:@event_queue).length
|
170
|
-
|
171
|
-
puts "✅ Event queue successful"
|
172
|
-
puts " Queue size before: #{queue_size_before}"
|
173
|
-
puts " Queue size after: #{queue_size_after}"
|
174
|
-
rescue => e
|
175
|
-
puts "❌ Event queue failed: #{e.message}"
|
176
|
-
end
|
177
|
-
|
178
|
-
puts "\n🎉 All tests completed!"
|
179
|
-
puts " This SDK is ready for use with Langfuse!"
|
180
|
-
puts " Remember to set your real API keys when using in production."
|
181
|
-
|
182
|
-
# Clean shutdown
|
183
|
-
client.shutdown
|
File without changes
|
File without changes
|