langfuse-rb 0.9.0 → 0.10.1
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 +19 -1
- data/README.md +8 -65
- data/lib/langfuse/api_client.rb +182 -261
- data/lib/langfuse/cache_constants.rb +32 -0
- data/lib/langfuse/cache_warmer.rb +21 -13
- data/lib/langfuse/chat_prompt_client.rb +3 -3
- data/lib/langfuse/client.rb +163 -150
- data/lib/langfuse/config.rb +15 -4
- data/lib/langfuse/prompt_cache.rb +145 -7
- data/lib/langfuse/prompt_cache_coordinator.rb +288 -0
- data/lib/langfuse/prompt_cache_events.rb +131 -0
- data/lib/langfuse/prompt_fetch_result.rb +122 -0
- data/lib/langfuse/rails_cache_adapter.rb +170 -9
- data/lib/langfuse/score_client.rb +12 -13
- data/lib/langfuse/stale_while_revalidate.rb +62 -19
- data/lib/langfuse/text_prompt_client.rb +2 -5
- data/lib/langfuse/version.rb +1 -1
- data/lib/langfuse.rb +4 -0
- metadata +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 06f62784113cec51196e77ba4604d8a056b0cd2fbeaccc950af44311cf428ae2
|
|
4
|
+
data.tar.gz: 96c3b104d313ed20a17ce199b7999cd91d4cf5a9f34482e7ef4d1a8508a00f0e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a5516b70bf74c36dd05c9766b5105d7ba9d249743b3b77f7136f73c7f4a2fe554cad109424ef4afc381f71cf5353d28248a97cce2e526c3cd8918a9a877250b8
|
|
7
|
+
data.tar.gz: 5eb592bf72abb6634413d7bb5de38cf188dac7cfae59cebbc7ee3810c875cdb4e2bbd037fca73165fa2e4b72ac966bf302b0629feabebd80adf128a04e7af7c7
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.10.1] - 2026-05-05
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- Refactor prompt cache internals (#91)
|
|
14
|
+
|
|
15
|
+
## [0.10.0] - 2026-05-05
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
- Expose prompt cache operations on the client (#89)
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
- Tighten cache event dispatch and generation safety for prompt caching (#90)
|
|
22
|
+
|
|
23
|
+
### Documentation
|
|
24
|
+
- Align README with sibling Langfuse SDKs (#88)
|
|
25
|
+
|
|
10
26
|
## [0.9.0] - 2026-04-28
|
|
11
27
|
|
|
12
28
|
### Added
|
|
@@ -113,7 +129,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
113
129
|
- Migrated from legacy ingestion API to OTLP endpoint
|
|
114
130
|
- Removed `tracing_enabled` configuration flag (#2)
|
|
115
131
|
|
|
116
|
-
[Unreleased]: https://github.com/simplepractice/langfuse-rb/compare/v0.
|
|
132
|
+
[Unreleased]: https://github.com/simplepractice/langfuse-rb/compare/v0.10.1...HEAD
|
|
133
|
+
[0.10.1]: https://github.com/simplepractice/langfuse-rb/compare/v0.10.0...v0.10.1
|
|
134
|
+
[0.10.0]: https://github.com/simplepractice/langfuse-rb/compare/v0.9.0...v0.10.0
|
|
117
135
|
[0.9.0]: https://github.com/simplepractice/langfuse-rb/compare/v0.8.0...v0.9.0
|
|
118
136
|
[0.8.0]: https://github.com/simplepractice/langfuse-rb/compare/v0.7.0...v0.8.0
|
|
119
137
|
[0.7.0]: https://github.com/simplepractice/langfuse-rb/compare/v0.6.0...v0.7.0
|
data/README.md
CHANGED
|
@@ -1,77 +1,20 @@
|
|
|
1
1
|
<img width="2255" height="527" alt="langfuse-wordart" src="https://github.com/user-attachments/assets/59422d0a-6ecb-4e5f-a21c-cae955b5ce75" />
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
# Langfuse Ruby SDK
|
|
5
4
|
|
|
6
|
-
[ - Open-source LLM observability and prompt management.
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://github.com/simplepractice/langfuse-rb/actions/workflows/ci.yml?query=branch%3Amain)
|
|
7
|
+
[](https://rubygems.org/gems/langfuse-rb)
|
|
11
8
|
|
|
12
9
|
## Installation
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Quick Start
|
|
11
|
+
> [!IMPORTANT]
|
|
12
|
+
> The SDK requires Ruby `>= 3.2.0`.
|
|
19
13
|
|
|
20
14
|
```ruby
|
|
21
|
-
|
|
22
|
-
config.public_key = ENV["LANGFUSE_PUBLIC_KEY"]
|
|
23
|
-
config.secret_key = ENV["LANGFUSE_SECRET_KEY"]
|
|
24
|
-
config.base_url = ENV.fetch("LANGFUSE_BASE_URL", "https://cloud.langfuse.com")
|
|
25
|
-
|
|
26
|
-
# Optional: sample traces and trace-linked scores deterministically
|
|
27
|
-
config.sample_rate = 1.0
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
message = Langfuse.client.compile_prompt(
|
|
31
|
-
"greeting",
|
|
32
|
-
variables: { name: "Alice" }
|
|
33
|
-
)
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
Langfuse tracing is isolated by default. `Langfuse.configure` stores configuration only; it does not replace `OpenTelemetry.tracer_provider`.
|
|
37
|
-
|
|
38
|
-
`sample_rate` is applied to traces and trace-linked scores. Rebuild the client with `Langfuse.reset!` before expecting runtime sampling changes to take effect.
|
|
39
|
-
|
|
40
|
-
## Trace an LLM Call
|
|
41
|
-
|
|
42
|
-
```ruby
|
|
43
|
-
Langfuse.observe("chat-completion", as_type: :generation) do |gen|
|
|
44
|
-
gen.model = "gpt-4.1-mini"
|
|
45
|
-
gen.input = [{ role: "user", content: "Hello!" }]
|
|
46
|
-
|
|
47
|
-
response = openai_client.chat(
|
|
48
|
-
parameters: {
|
|
49
|
-
model: "gpt-4.1-mini",
|
|
50
|
-
messages: [{ role: "user", content: "Hello!" }]
|
|
51
|
-
}
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
gen.update(
|
|
55
|
-
output: response.dig("choices", 0, "message", "content"),
|
|
56
|
-
usage_details: {
|
|
57
|
-
prompt_tokens: response.dig("usage", "prompt_tokens"),
|
|
58
|
-
completion_tokens: response.dig("usage", "completion_tokens")
|
|
59
|
-
}
|
|
60
|
-
)
|
|
61
|
-
end
|
|
15
|
+
gem "langfuse-rb"
|
|
62
16
|
```
|
|
63
17
|
|
|
64
|
-
##
|
|
65
|
-
|
|
66
|
-
- [Documentation Hub](docs/README.md)
|
|
67
|
-
- [Getting Started](docs/GETTING_STARTED.md)
|
|
68
|
-
- [Prompts](docs/PROMPTS.md)
|
|
69
|
-
- [Tracing](docs/TRACING.md)
|
|
70
|
-
- [Scoring](docs/SCORING.md)
|
|
71
|
-
- [Rails Patterns](docs/RAILS.md)
|
|
72
|
-
- [Agent Skills](https://github.com/langfuse/skills)
|
|
73
|
-
- [Agent Skill Docs](https://langfuse.com/docs/api-and-data-platform/features/agent-skill)
|
|
74
|
-
|
|
75
|
-
## License
|
|
18
|
+
## Docs
|
|
76
19
|
|
|
77
|
-
[
|
|
20
|
+
Please [see our docs](docs/README.md) for detailed information on this SDK.
|