helicone-rb 0.0.4 → 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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/helicone/version.rb +1 -1
  3. data/sample.rb +177 -0
  4. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e47a2406f0ff4091abc0a4720eaa015bd157b76dc8c231c1d9b3e6fe2ed97c4
4
- data.tar.gz: 6c9debdd6b54fead261c3ba10b7cee76aa25b4e0ea15c1b3324b1e8d56713ff7
3
+ metadata.gz: 30551d818f767a29ad080d1ec1beffc42a5346e0e4f94f9cbe112b6c7aaaa9b5
4
+ data.tar.gz: 3505af534452304f15f075a0fbde6d334c8a1b3cc8a4a85f61abc292fe564226
5
5
  SHA512:
6
- metadata.gz: d06ffd02119a05aa69abffd784e545f00c914554e2ccf36c7dce952aa24417055ba6ea4d10c17d6979d736b754f19d6bdfbad04044d02f91ddc6ce4df1c95960
7
- data.tar.gz: 20f39820ca78bd10e6ff7205b42cd78f24865632281da0c07456b2c5af5ff90f49ab79f1e48984cbffa5cffc6c1c455ed424ab5c5c47a84486d5758193730a10
6
+ metadata.gz: 2e09d82c356de9e0ca25af6846e582c63bbc773fab7c7f257e0e06a2dcf4ebbb0ee6af983457a7fd61fa9b5ec84116e7621017cf4fb8216649bdfc23fd6d14a9
7
+ data.tar.gz: 44affe9ff8922ba1254567b88cb7ac4b280aa3b95eac4162969c6ac606e6be5194f8b2b1784feaba1cdc73d340d67cef078f5bf7e63b4caa36b401a02ce384d8
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Helicone
4
- VERSION = "0.0.4"
4
+ VERSION = "0.1.0"
5
5
  end
data/sample.rb ADDED
@@ -0,0 +1,177 @@
1
+ require 'helicone'
2
+
3
+
4
+ # ============================================
5
+ # Configuration
6
+ # ============================================
7
+
8
+ Helicone.configure do |config|
9
+ config.default_model = "gpt-4o-mini"
10
+ config.logger = Logger.new(STDOUT, level: Logger::DEBUG)
11
+ end
12
+
13
+ if ENV["HELICONE_API_KEY"].nil?
14
+ fail StandardError, "HELICONE_API_KEY is not set"
15
+ end
16
+
17
+ # ============================================
18
+ # Basic Usage - Simple Questions
19
+ # ============================================
20
+
21
+ client = Helicone::Client.new
22
+ client.ask("What is 2 + 2?")
23
+ # => "2 + 2 equals 4."
24
+
25
+ # With a system prompt
26
+ client.ask("Tell me a joke", system: "You are a comedian")
27
+
28
+ # With a specific model
29
+ client.ask("Explain Ruby blocks", model: "gpt-4o-mini")
30
+
31
+ # ============================================
32
+ # With Session/Account Tracking
33
+ # ============================================
34
+
35
+ client = Helicone::Client.new(
36
+ session_id: "conv_123",
37
+ session_name: "Customer Support Chat",
38
+ account_id: "user_456",
39
+ account_name: "Acme Corp"
40
+ )
41
+
42
+ client.ask("Help me with my order")
43
+
44
+ # ============================================
45
+ # Multi-turn Conversation
46
+ # ============================================
47
+
48
+ client = Helicone::Client.new
49
+ messages = [
50
+ Helicone::Message.system("You are a helpful assistant"),
51
+ Helicone::Message.user_text("My name is Alice")
52
+ ]
53
+
54
+ response = client.chat(messages: messages)
55
+ puts response.content
56
+ # => "Nice to meet you, Alice!"
57
+
58
+ messages << response.to_message
59
+ messages << Helicone::Message.user_text("What's my name?")
60
+
61
+ response = client.chat(messages: messages)
62
+ puts response.content
63
+ # => "Your name is Alice."
64
+
65
+ # ============================================
66
+ # Vision - Ask About Images
67
+ # ============================================
68
+
69
+ client.ask_with_image(
70
+ "What's in this image?",
71
+ "https://example.com/photo.jpg",
72
+ detail: "high"
73
+ )
74
+
75
+ # ============================================
76
+ # Using the Agent with Tools
77
+ # ============================================
78
+
79
+ # Define a tool
80
+ class WeatherTool < Helicone::Tool
81
+ description "Get current weather for a location"
82
+
83
+ parameters(
84
+ type: "object",
85
+ properties: {
86
+ location: { type: "string", description: "City name" }
87
+ },
88
+ required: ["location"]
89
+ )
90
+
91
+ def execute(location:)
92
+ # In reality, call a weather API
93
+ { temperature: 72, conditions: "sunny", location: location }
94
+ end
95
+ end
96
+
97
+ class CalculatorTool < Helicone::Tool
98
+ description "Evaluate a math expression"
99
+
100
+ parameters(
101
+ type: "object",
102
+ properties: {
103
+ expression: { type: "string", description: "Math expression like '2 + 2'" }
104
+ },
105
+ required: ["expression"]
106
+ )
107
+
108
+ def execute(expression:)
109
+ { result: eval(expression) }
110
+ rescue => e
111
+ { error: e.message }
112
+ end
113
+ end
114
+
115
+ # Run the agent
116
+ agent = Helicone::Agent.new(
117
+ tools: [WeatherTool, CalculatorTool],
118
+ system: "You are a helpful assistant with access to weather and calculator tools."
119
+ )
120
+
121
+ result = agent.run("What's the weather in San Francisco?")
122
+ puts result.content
123
+ puts "Iterations: #{result.iterations}"
124
+ puts "Tool calls made: #{result.tool_calls_made}"
125
+
126
+ # Continue the conversation
127
+ result = agent.continue("What about New York?")
128
+ puts result.content
129
+
130
+ # ============================================
131
+ # Agent with Context
132
+ # ============================================
133
+
134
+ # Context is passed to tool instances
135
+ class DatabaseTool < Helicone::Tool
136
+ description "Query the database"
137
+
138
+ parameters(
139
+ type: "object",
140
+ properties: {
141
+ query: { type: "string" }
142
+ },
143
+ required: ["query"]
144
+ )
145
+
146
+ def execute(query:)
147
+ # Access context passed from agent
148
+ user_id = context[:user_id]
149
+ { results: "Data for user #{user_id}: #{query}" }
150
+ end
151
+ end
152
+
153
+ agent = Helicone::Agent.new(
154
+ tools: [DatabaseTool],
155
+ context: { user_id: 123, db: some_db_connection }
156
+ )
157
+
158
+ result = agent.run("Find my recent orders")
159
+
160
+ # ============================================
161
+ # Inspecting Responses
162
+ # ============================================
163
+
164
+ client = Helicone::Client.new
165
+ response = client.chat(
166
+ messages: [Helicone::Message.user_text("Hello")]
167
+ )
168
+
169
+ response.content # => "Hello! How can I help?"
170
+ response.role # => "assistant"
171
+ response.model # => "gpt-4o"
172
+ response.finish_reason # => "stop"
173
+ response.prompt_tokens # => 10
174
+ response.completion_tokens # => 15
175
+ response.total_tokens # => 25
176
+ response.success? # => true
177
+ response.raw # => full raw response hash
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helicone-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genevere
@@ -93,6 +93,7 @@ files:
93
93
  - readme-assets/helicone-dashboard.png
94
94
  - readme-assets/helicone-model-registry.png
95
95
  - readme-assets/helicone-session-flamegraph.png
96
+ - sample.rb
96
97
  homepage: https://github.com/genevere-inc/helicone-rb
97
98
  licenses:
98
99
  - MIT