ruby-magicwrite 0.1.0 → 0.1.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 +10 -2
- data/Gemfile.lock +1 -1
- data/lib/magicwrite/http.rb +0 -12
- data/lib/magicwrite/version.rb +1 -1
- 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: a0c716f7c2b2ce16a998fd91bf887347655f93ae07e1a895e09c6ee6b857e43f
|
|
4
|
+
data.tar.gz: 7c5091fa210d5550b2b8d11ff5ca1c918328702052eee631bec8d661b4453856
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1c403e98fd0c52c5963cc2dd931bf177c87b7ef826f7a270ff716df0623d0b112fb635c6f7f599e1d27b5dd31ac908bea51dc726d5b6ae0ea15b418ad4098c11
|
|
7
|
+
data.tar.gz: 766121aa9ed0e0bb7083d870d80f5428a451792707675672a4ce55ddfe16af1a3e81151cf2aa3c23f81857943a4cf6831a32d74574f0c645f099d83baa426055
|
data/CHANGELOG.md
CHANGED
|
@@ -5,10 +5,18 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.1.1] - 2023-06-21
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- CHANGELOG
|
|
13
|
+
- README
|
|
14
|
+
|
|
15
|
+
|
|
8
16
|
## [0.1.0] - 2023-06-21
|
|
9
17
|
|
|
10
18
|
### Added
|
|
11
19
|
|
|
12
20
|
- Initialise repository.
|
|
13
|
-
- Add MagicWrite::Client to connect to
|
|
14
|
-
|
|
21
|
+
- Add MagicWrite::Client to connect to MagicWrite API using user tokens.
|
|
22
|
+
|
data/Gemfile.lock
CHANGED
data/lib/magicwrite/http.rb
CHANGED
|
@@ -55,18 +55,9 @@ module MagicWrite
|
|
|
55
55
|
|
|
56
56
|
JSON.parse(string)
|
|
57
57
|
rescue JSON::ParserError
|
|
58
|
-
# Convert a multiline string of JSON objects to a JSON array.
|
|
59
58
|
JSON.parse(string.gsub("}\n{", '},{').prepend('[').concat(']'))
|
|
60
59
|
end
|
|
61
60
|
|
|
62
|
-
# Given a proc, returns an outer proc that can be used to iterate over a JSON stream of chunks.
|
|
63
|
-
# For each chunk, the inner user_proc is called giving it the JSON object. The JSON object could
|
|
64
|
-
# be a data object or an error object as described in the OpenAI API documentation.
|
|
65
|
-
#
|
|
66
|
-
# If the JSON object for a given data or error message is invalid, it is ignored.
|
|
67
|
-
#
|
|
68
|
-
# @param user_proc [Proc] The inner proc to call for each JSON object in the chunk.
|
|
69
|
-
# @return [Proc] An outer proc that iterates over a raw stream, converting it to JSON.
|
|
70
61
|
def to_json_stream(user_proc:)
|
|
71
62
|
proc do |chunk, _|
|
|
72
63
|
chunk.scan(/(?:data|error): (\{.*\})/i).flatten.each do |data|
|
|
@@ -99,9 +90,6 @@ module MagicWrite
|
|
|
99
90
|
parameters&.transform_values do |value|
|
|
100
91
|
next value unless value.is_a?(File)
|
|
101
92
|
|
|
102
|
-
# Doesn't seem like OpenAI need mime_type yet, so not worth
|
|
103
|
-
# the library to figure this out. Hence the empty string
|
|
104
|
-
# as the second argument.
|
|
105
93
|
Faraday::UploadIO.new(value, '', value.path)
|
|
106
94
|
end
|
|
107
95
|
end
|
data/lib/magicwrite/version.rb
CHANGED