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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3cac8e5659bd9a13198a6efa899fd07ae8cdb00a4fa0281ce210dd57e39e1100
4
- data.tar.gz: fe72c126c9a13ea62bf09103bd1e0633a43e291b553a26ad17cd82d1e8cceef6
3
+ metadata.gz: 2102ae80fc0527c40e5d1b527bce6220811a7f37b3fec31c71f22c088c3f0aa6
4
+ data.tar.gz: 27de89212f5ae2f16e59ef8a6c504d4595409a0e3b11055d87d516ec613df8a4
5
5
  SHA512:
6
- metadata.gz: de7070e1e4be16c2e44fab3ef2eab7fac21976bcf45b3976647a86d4ae80b217d85fccde809e9b2d1f37edd12f66ea0d49bd81b22e182ce8eb067f3230a2031b
7
- data.tar.gz: 0ede79ecff4548733a9c06dc741a5d0da606e09740c2083468d8a1c6bdb9eb1de4126d886b9eabcf95ca787deba95bf734cbb3c8074ad122362a893d9e691f11
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- xfyun-spark (0.1.0)
4
+ xfyun-spark (0.1.2)
5
5
  faye-websocket
6
6
 
7
7
  GEM
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Xfyun
2
2
  module Spark
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
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.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-18 00:00:00.000000000 Z
11
+ date: 2023-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faye-websocket