omniai 1.6.4 → 1.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/omniai/chat/file.rb +16 -3
- data/lib/omniai/chat/url.rb +16 -6
- data/lib/omniai/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: 5d9011a55d57b9dd0923f4d7edd70001c3f9ee5b8211e98d59f9d001687af044
|
4
|
+
data.tar.gz: 204e2f0ec0a44f65cba11cb49819e7f5c4e933a92d6bc1b48c4d630dee180ecd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 724827923255adade8f19bd9b43806d1af116d9c4dd6105713f0ba0b16c3d6cd5e5cbafdc2d324912a669523e565ba1ce190ed26035cdc1645a4505f2c6991a9
|
7
|
+
data.tar.gz: 5944ef3f285359662fc6105fd2a3aba7a44a279c5062ec0c1bdf194ddecd6842a33b1cd9b20cd4f5b36641b67cd8bc046e677260170d06dd2d5e3b37db37f356
|
data/lib/omniai/chat/file.rb
CHANGED
@@ -29,10 +29,23 @@ module OmniAI
|
|
29
29
|
# @param context [Context]
|
30
30
|
# @return [Hash]
|
31
31
|
def serialize(context: nil)
|
32
|
-
|
33
|
-
|
32
|
+
if text?
|
33
|
+
content = fetch!
|
34
|
+
Text.new("<file>#{filename}: #{content}</file>").serialize(context:)
|
35
|
+
else
|
36
|
+
serializer = context&.serializers&.[](:file)
|
37
|
+
return serializer.call(self, context:) if serializer
|
34
38
|
|
35
|
-
|
39
|
+
{ type: "#{kind}_url", "#{kind}_url": { url: data_uri } }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# @return [String]
|
44
|
+
def filename
|
45
|
+
case @io
|
46
|
+
when Tempfile, File, String then ::File.basename(@io)
|
47
|
+
else 'DATA'
|
48
|
+
end
|
36
49
|
end
|
37
50
|
end
|
38
51
|
end
|
data/lib/omniai/chat/url.rb
CHANGED
@@ -36,13 +36,18 @@ module OmniAI
|
|
36
36
|
#
|
37
37
|
# @return [Hash]
|
38
38
|
def serialize(context: nil)
|
39
|
-
|
40
|
-
|
39
|
+
if text?
|
40
|
+
content = fetch!
|
41
|
+
Text.new("<file>#{filename}: #{content}</file>").serialize(context:)
|
42
|
+
else
|
43
|
+
serializer = context&.serializers&.[](:url)
|
44
|
+
return serializer.call(self, context:) if serializer
|
41
45
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
+
{
|
47
|
+
type: "#{kind}_url",
|
48
|
+
"#{kind}_url": { url: @uri },
|
49
|
+
}
|
50
|
+
end
|
46
51
|
end
|
47
52
|
|
48
53
|
# @raise [FetchError]
|
@@ -53,6 +58,11 @@ module OmniAI
|
|
53
58
|
String(response.body)
|
54
59
|
end
|
55
60
|
|
61
|
+
# @return [String]
|
62
|
+
def filename
|
63
|
+
::File.basename(@uri)
|
64
|
+
end
|
65
|
+
|
56
66
|
protected
|
57
67
|
|
58
68
|
# @raise [FetchError]
|
data/lib/omniai/version.rb
CHANGED