ai-chat 0.5.5 → 0.5.6
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/README.md +16 -0
- data/ai-chat.gemspec +1 -1
- data/lib/ai/chat.rb +6 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a8573f38afcb8919bc8a4c7612cd8d99ee54fa9271ee974fc1c266af3a6daaa5
|
|
4
|
+
data.tar.gz: 021e2c5e81597b2154142f65b4771932b615361b40c41d8e855675fb0db88a90
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1ccf46c12086468abc44ecc967ed7ef3c52f19661ebe862f1516b79fd504e8b801300785cb39f7e8195443b55b8e101beb01955ca66bf43550f6f14d261e3fd6
|
|
7
|
+
data.tar.gz: 74dcc5634d3eaaa4d9f6b3e123e91b016385883e9c4a3bfb4d71904fde07651d79bad711dfe1f3e2735d31a153e8d0d9efc0a6593b887be2d728364c99160244
|
data/README.md
CHANGED
|
@@ -414,6 +414,14 @@ AI::Chat.generate_schema!("A user with full name (required), first_name (require
|
|
|
414
414
|
AI::Chat.generate_schema!("A user with full name (required), first_name (required), and last_name (required).", api_key_env_var: "CUSTOM_KEY")
|
|
415
415
|
```
|
|
416
416
|
|
|
417
|
+
`generate_schema!` also follows proxy defaults from the `AICHAT_PROXY` environment variable. Proxy is enabled only when `AICHAT_PROXY` is exactly `"true"`.
|
|
418
|
+
|
|
419
|
+
```bash
|
|
420
|
+
export AICHAT_PROXY=true
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
If you pass `proxy: true` or `proxy: false`, that explicit value overrides the env default.
|
|
424
|
+
|
|
417
425
|
You can choose a location for the schema to save by using the `location` keyword argument.
|
|
418
426
|
|
|
419
427
|
```rb
|
|
@@ -622,6 +630,14 @@ puts chat.last[:content]
|
|
|
622
630
|
# => "Once upon a time..."
|
|
623
631
|
```
|
|
624
632
|
|
|
633
|
+
You can also default proxy mode from the environment for both `AI::Chat.new` and `AI::Chat.generate_schema!`:
|
|
634
|
+
|
|
635
|
+
```bash
|
|
636
|
+
export AICHAT_PROXY=true
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
Proxy is enabled only when `AICHAT_PROXY` is exactly `"true"`. Any other value (including `"TRUE"` or `"1"`) leaves proxy disabled unless you explicitly set `chat.proxy = true` or pass `proxy: true`.
|
|
640
|
+
|
|
625
641
|
When proxy is enabled, **you must use the API key provided by prepend.me** in place of a real OpenAI API key. Refer to [the section on API keys](#api-key) for options on how to set your key.
|
|
626
642
|
|
|
627
643
|
## Building Conversations Without API Calls
|
data/ai-chat.gemspec
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |spec|
|
|
4
4
|
spec.name = "ai-chat"
|
|
5
|
-
spec.version = "0.5.
|
|
5
|
+
spec.version = "0.5.6"
|
|
6
6
|
spec.authors = ["Raghu Betina", "Jelani Woods"]
|
|
7
7
|
spec.email = ["raghu@firstdraft.com", "jelani@firstdraft.com"]
|
|
8
8
|
spec.homepage = "https://github.com/firstdraft/ai-chat"
|
data/lib/ai/chat.rb
CHANGED
|
@@ -25,11 +25,13 @@ module AI
|
|
|
25
25
|
|
|
26
26
|
def initialize(api_key: nil, api_key_env_var: "OPENAI_API_KEY")
|
|
27
27
|
@api_key = api_key || ENV.fetch(api_key_env_var)
|
|
28
|
-
@proxy =
|
|
28
|
+
@proxy = ENV["AICHAT_PROXY"] == "true"
|
|
29
29
|
@messages = []
|
|
30
30
|
@reasoning_effort = nil
|
|
31
31
|
@model = "gpt-5.2"
|
|
32
|
-
|
|
32
|
+
client_options = {api_key: @api_key}
|
|
33
|
+
client_options[:base_url] = BASE_PROXY_URL if @proxy
|
|
34
|
+
@client = OpenAI::Client.new(**client_options)
|
|
33
35
|
@last_response_id = nil
|
|
34
36
|
@image_generation = false
|
|
35
37
|
@image_folder = "./images"
|
|
@@ -37,8 +39,9 @@ module AI
|
|
|
37
39
|
@verbosity = :medium
|
|
38
40
|
end
|
|
39
41
|
|
|
40
|
-
def self.generate_schema!(description, location: "schema.json", api_key: nil, api_key_env_var: "OPENAI_API_KEY", proxy:
|
|
42
|
+
def self.generate_schema!(description, location: "schema.json", api_key: nil, api_key_env_var: "OPENAI_API_KEY", proxy: nil)
|
|
41
43
|
api_key ||= ENV.fetch(api_key_env_var)
|
|
44
|
+
proxy = ENV["AICHAT_PROXY"] == "true" if proxy.nil?
|
|
42
45
|
prompt_path = File.expand_path("../prompts/schema_generator.md", __dir__)
|
|
43
46
|
system_prompt = File.read(prompt_path)
|
|
44
47
|
|