ask-agent 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cc1ea1b84a7139944acf9787cfdd3e5a9fad739b759fc4501f59f68bdd3c0b77
4
- data.tar.gz: 37733f0982e0d991e284d46c9202fe5846fff67a433acae0385a703912c7f898
3
+ metadata.gz: bb3f240855fe04ef37b3d474cd4f9ddae5db28256673aa1d1804bdfbc1a8836c
4
+ data.tar.gz: 84684f83697510a261de607ede4a6aafd2a396a2151d169290769148214bc4a0
5
5
  SHA512:
6
- metadata.gz: 8e4ff593f7856c2fe0da46dfe8091ad38217e29b27aa343e95f6f939ab741b8c249217dbaa397ad609c21b9b4f39e09a781738a556368e69307fa01329fb00d9
7
- data.tar.gz: fc45d3ae62bc2e325a22dedab88625f312d3e9b07188d9614c5cb2ddfa9683ed31e2bb8473f10344d73ac18f7cef202fcf53cd68272affbab54c208770017dde
6
+ metadata.gz: 41ac967bf49f11bea0d4a65d9984ddfc0838007096b153c2294691abd8ce3bdd60aae0890e10f7bfed39ce2ed0b7f71f577e33d10a029f1660c6b779b4117f13
7
+ data.tar.gz: e097d8c0bbd5bf5f78cccc49fd167d951119d91ee473915803c92dfbbae245167b95050ad321ba2ccfbed71fc3c224effe30252c2badeff8c6fbb07f624c801e
@@ -26,8 +26,11 @@ module Ask
26
26
  # internal usage (Hash of { id => ToolCallInfo }).
27
27
  class Chat
28
28
  # @return [String] model ID (e.g. "gpt-4o")
29
- attr_reader :model
30
-
29
+ attr_reader :model_id
30
+ # @return [String] model ID (e.g. "gpt-4o")
31
+ def model
32
+ @model_id
33
+ end
31
34
  # @return [Array<Ask::Message>] all messages in the conversation
32
35
  attr_reader :messages
33
36
 
@@ -35,13 +38,17 @@ module Ask
35
38
  # @param tools [Array<Ask::Tool>] tool instances available to the chat
36
39
  # @param temperature [Float, nil] sampling temperature
37
40
  # @param schema [Ask::Schema, Hash, nil] structured output schema
38
- def initialize(model:, tools: [], temperature: nil, schema: nil, **)
41
+ # @param assume_model_exists [Boolean] whether to skip model catalog lookup
42
+ # @param provider [String, Symbol, nil] provider slug to use (overrides model catalog)
43
+ def initialize(model:, tools: [], temperature: nil, schema: nil,
44
+ assume_model_exists: false, provider: nil, **)
39
45
  @model_id = model.respond_to?(:id) ? model.id : model.to_s
40
- @model_info = resolve_model(@model_id)
46
+ @model_info = resolve_model(@model_id) unless assume_model_exists
41
47
  @tools = tools
42
48
  @temperature = temperature
43
49
  @schema = schema
44
50
  @messages = []
51
+ @provider_override = provider
45
52
  @provider = nil
46
53
  end
47
54
 
@@ -123,6 +130,15 @@ module Ask
123
130
  self
124
131
  end
125
132
 
133
+ # Set the structured output schema and return self.
134
+ #
135
+ # @param schema [Ask::Schema, Hash] structured output schema
136
+ # @return [self]
137
+ def with_schema(schema)
138
+ @schema = schema.respond_to?(:to_json_schema) ? schema.to_json_schema : schema
139
+ self
140
+ end
141
+
126
142
  # Clear all messages from the conversation.
127
143
  def reset_messages!
128
144
  @messages.clear
@@ -143,19 +159,19 @@ module Ask
143
159
  end
144
160
 
145
161
  def build_provider
146
- slug = @model_info&.provider || "openai"
162
+ slug = @provider_override&.to_s || @model_info&.provider || "openai"
147
163
  klass = Ask::Provider.resolve(slug)
148
164
  klass.new(provider_config(slug))
149
165
  end
150
166
 
151
167
  def provider_config(slug, extra_keys: {})
152
- env_key = "#{slug.upcase}_API_KEY"
153
- key = ENV[env_key] || ENV["OPENCODE_API_KEY"] || ENV["OPENAI_API_KEY"]
154
- base = ENV["#{slug.upcase}_API_BASE"] || ENV["OPENCODE_API_BASE"]
155
- config = { api_key: key }
156
- config[:"#{slug}_api_key"] = key
157
- config[:"#{slug}_api_base"] = base if base
158
- Ask::LLM::Config.new(config)
168
+ env_key = "#{slug.upcase}_API_KEY"
169
+ key = ENV[env_key] || ENV["OPENCODE_API_KEY"] || ENV["OPENAI_API_KEY"]
170
+ base = ENV["#{slug.upcase}_API_BASE"] || ENV["OPENCODE_API_BASE"]
171
+ config = { api_key: key }
172
+ config[:"#{slug}_api_key"] = key
173
+ config[:"#{slug}_api_base"] = base if base
174
+ Ask::LLM::Config.new(config)
159
175
  end
160
176
 
161
177
  # Accumulate partial tool calls from streaming chunks.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ask
4
4
  module Agent
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ask-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaka Ruto