xfyun-spark 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/lib/xfyun/spark/request.rb +8 -6
- data/lib/xfyun/spark/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2102ae80fc0527c40e5d1b527bce6220811a7f37b3fec31c71f22c088c3f0aa6
|
4
|
+
data.tar.gz: 27de89212f5ae2f16e59ef8a6c504d4595409a0e3b11055d87d516ec613df8a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe0d3454e91e8f0cf9f16f98aae6c7a72fb7407eabcf72d22557b20f0ea1c297278552b0595829b3e20a478061f6aed603531a4273ad210bea13d8338ab57efd
|
7
|
+
data.tar.gz: 18cd8d389212e1eed574d15ec5ac31044c86e42883c8e2ddd10a37d64ce910ef8b9b5ad43762fa4949a39dbaa337b146a6b330a67521995ab6ccfc65798fb329
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,13 @@ 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.2] - 2023-09-20
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
|
12
|
+
- raise exception when ws onerror
|
13
|
+
- fixed last message content missing
|
14
|
+
|
8
15
|
## [0.1.1] - 2023-09-19
|
9
16
|
|
10
17
|
### Changed
|
data/Gemfile.lock
CHANGED
data/lib/xfyun/spark/request.rb
CHANGED
@@ -14,26 +14,27 @@ module Xfyun
|
|
14
14
|
data = nil
|
15
15
|
EM.run {
|
16
16
|
url = authorization_url(path)
|
17
|
-
puts url
|
18
|
-
puts parameters
|
17
|
+
# puts url
|
18
|
+
# puts parameters
|
19
19
|
ws = Faye::WebSocket::Client.new(url)
|
20
20
|
|
21
21
|
ws.on(:open) do |event|
|
22
|
-
p [:open, ws.headers]
|
22
|
+
# p [:open, ws.headers]
|
23
23
|
ws.send(parameters.to_json)
|
24
24
|
end
|
25
25
|
|
26
26
|
ws.on(:close) do |event|
|
27
|
-
p [:close, event.code, event.reason]
|
27
|
+
# p [:close, event.code, event.reason]
|
28
28
|
EM.stop
|
29
29
|
end
|
30
30
|
|
31
31
|
ws.on(:error) do |event|
|
32
|
-
p [:error, event.message]
|
32
|
+
# p [:error, event.message]
|
33
|
+
raise Xfyun::Spark::Error.new(event.message)
|
33
34
|
end
|
34
35
|
|
35
36
|
ws.on(:message) do |event|
|
36
|
-
p [:message, event.data]
|
37
|
+
# p [:message, event.data]
|
37
38
|
response_data = JSON.parse(event.data)
|
38
39
|
code = response_data.dig('header', 'code')
|
39
40
|
if code == 0
|
@@ -43,6 +44,7 @@ module Xfyun
|
|
43
44
|
content << response_data.dig('payload', 'choices', 'text', 0, 'content')
|
44
45
|
when 2
|
45
46
|
# last message
|
47
|
+
content << response_data.dig('payload', 'choices', 'text', 0, 'content')
|
46
48
|
response_data['payload']['choices']['text'][0]['content'] = content
|
47
49
|
data = response_data
|
48
50
|
end
|
data/lib/xfyun/spark/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xfyun-spark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chaucerling
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faye-websocket
|