openai-assistant 1.0.0 → 1.1.0

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: 44a58132dffbb0bb717d0c0f5c5760a222f88fde9f7cc9721e8ed0d91788e5bb
4
- data.tar.gz: 45c2cebb8c681541526685d0c2ce90631cff61c7d0d7a72eb85b93c17b7fa23d
3
+ metadata.gz: 1d903e8d269b7951b68f30be711b1891f4175ae828f0ef57aa52896971604920
4
+ data.tar.gz: 2b310fe5f7423d00f57760d9a0a48c715b6617bd592d98ad5c04f07fdb76e4e7
5
5
  SHA512:
6
- metadata.gz: 37399c1452826279d1065a4a0829b0077fe017283e51b796055ff2830740bb668449ec90ec77109155c7b84d617fc7bd8643870e40537f4b77b9e13da90b98cc
7
- data.tar.gz: a59828b4b77ea422d0aabfb2adcef8e499f5300514c42e4e45f69e09394b00234164cce72c6e25d597aa15396ab9dc9e2189a6bc3dc37e3cc617adc3f7268d9e
6
+ metadata.gz: ab128129583233462bde63adb5ca0dce2799313b362e0c8632d86046803a39c8d57dde423736b34e931b1cf797a0ff539dd19e4deee88f048b6628a8723b3b4b
7
+ data.tar.gz: cdd30bd9901b70e7c1bc7bb4a749b9e6c37d6450be09e4494f606f3a7f33da8412016f01ba36da43de5c1ce32a8d24beda60e245cd28f93cc1cce2a4532992a8
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # OpenaiAsissistant::Assistant
1
+ # OpenaiAssistant::Assistant
2
2
  This project/gem is for Ruby interact with OpenAI Assistant throught rest api.
3
3
 
4
- The client to call is: `OpenaiAsissistant::Assistant`
4
+ The client to call is: `OpenaiAssistant::Assistant`
5
5
 
6
6
  ## Installation
7
7
  Install throught RubyGems server by below step:
@@ -14,7 +14,7 @@ Install throught RubyGems server by below step:
14
14
  You can direct interact with gem by:
15
15
 
16
16
  - use the gem `require "openai/assistant"`
17
- - setup the api key `instance =OpenaiAsissistant::Assistant::new(${API_KEY})`
17
+ - setup the api key `instance = OpenaiAssistant::Assistant::new(${API_KEY})`
18
18
  - interact with assistant:
19
19
  + `instance.create_assistant(model, instruction)`
20
20
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module OpenaiAsissistant
3
+ module OpenaiAssistant
4
4
  # Base class of openai
5
5
  class Base
6
6
  def initialize(api_key = "")
@@ -8,7 +8,7 @@ module OpenaiAsissistant
8
8
  # hard the host because if the official docs change the host, maybe it will change another
9
9
  # we need to update this gem for any change
10
10
  @openai_url = "https://api.openai.com/v1/assistants"
11
- @http_client = OpenaiAsissistant::HTTPClient.new
11
+ @http_client = OpenaiAssistant::HTTPClient.new
12
12
  end
13
13
 
14
14
  def default_headers
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module OpenaiAsissistant
3
+ module OpenaiAssistant
4
4
  module Assistant
5
5
  # An openai assistant client
6
6
  class Client
@@ -11,19 +11,19 @@ module OpenaiAsissistant
11
11
  end
12
12
 
13
13
  def create_assistant(model, instructions)
14
- OpenaiAsissistant::Assistant::Create.new(@api_key).create_assistant(model, instructions)
14
+ OpenaiAssistant::Assistant::Create.new(@api_key).create_assistant(model, instructions)
15
15
  end
16
16
 
17
17
  def retrieve_assistant(assistant_id)
18
- OpenaiAsissistant::Assistant::Retrieve.new(@api_key).retrieve_assistant(assistant_id)
18
+ OpenaiAssistant::Assistant::Retrieve.new(@api_key).retrieve_assistant(assistant_id)
19
19
  end
20
20
 
21
21
  def list_assistant
22
- OpenaiAsissistant::Assistant::List.new(@api_key).list_assistant
22
+ OpenaiAssistant::Assistant::List.new(@api_key).list_assistant
23
23
  end
24
24
 
25
25
  def delete_assistant(assistant_id)
26
- OpenaiAsissistant::Assistant::Delete.new(@api_key).delete_assistant(assistant_id)
26
+ OpenaiAssistant::Assistant::Delete.new(@api_key).delete_assistant(assistant_id)
27
27
  end
28
28
  end
29
29
  end
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module OpenaiAsissistant
3
+ module OpenaiAssistant
4
4
  module Assistant
5
5
  # An openai assistant
6
6
  class Create < Base
7
7
  # @param model [String] Select model of the assistant. refer on: https://platform.openai.com/docs/api-reference/models/list.
8
8
  # @param instructions [String] The system instructions that the assistant uses.
9
- # @return [OpenaiAsissistant::Mapper::Assistant] A new response object of assistant.
9
+ # @return [OpenaiAssistant::Mapper::Assistant] A new response object of assistant.
10
10
  def create_assistant(model, instructions)
11
11
  url = URI.parse(@openai_url)
12
12
  req_body = {
@@ -16,9 +16,9 @@ module OpenaiAsissistant
16
16
  "model": model
17
17
  }.to_json
18
18
  response = @http_client.call_post(url, req_body, default_headers)
19
- return OpenaiAsissistant::ErrorResponse.from_json(response.body) unless response.code == "200"
19
+ return OpenaiAssistant::ErrorResponse.from_json(response.body) unless response.code == "200"
20
20
 
21
- OpenaiAsissistant::Mapper::Assistant.from_json(JSON.parse(response.body))
21
+ OpenaiAssistant::Mapper::Assistant.from_json(JSON.parse(response.body))
22
22
  end
23
23
  end
24
24
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module OpenaiAsissistant
3
+ module OpenaiAssistant
4
4
  module Assistant
5
5
  # An openai assistant
6
6
  class Delete < Base
@@ -10,7 +10,7 @@ module OpenaiAsissistant
10
10
  url = "#{@openai_url}/#{assistant_id}"
11
11
  uri = URI(url)
12
12
  response = @http_client.call_delete(uri, default_headers)
13
- return OpenaiAsissistant::ErrorResponse.from_json(response.body) unless response.code == "200"
13
+ return OpenaiAssistant::ErrorResponse.from_json(response.body) unless response.code == "200"
14
14
 
15
15
  true
16
16
  end
@@ -1,20 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module OpenaiAsissistant
3
+ module OpenaiAssistant
4
4
  module Assistant
5
5
  # An openai assistant
6
6
  class List < Base
7
- # @return [Array<OpenaiAsissistant::Mapper::Assistant>] List all assistant
7
+ # @return [Array<OpenaiAssistant::Mapper::Assistant>] List all assistant
8
8
  def list_assistant
9
9
  url = @openai_url
10
10
  uri = URI(url)
11
11
  response = @http_client.call_get(uri, default_headers)
12
- return OpenaiAsissistant::ErrorResponse.from_json(response.body) unless response.code == "200"
12
+ return OpenaiAssistant::ErrorResponse.from_json(response.body) unless response.code == "200"
13
13
 
14
14
  parsed = JSON.parse(response.body)
15
15
  assistants = []
16
16
  parsed["data"].each do |ast|
17
- assistants << OpenaiAsissistant::Mapper::Assistant.from_json(ast)
17
+ assistants << OpenaiAssistant::Mapper::Assistant.from_json(ast)
18
18
  end
19
19
  end
20
20
  end
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module OpenaiAsissistant
3
+ module OpenaiAssistant
4
4
  module Assistant
5
5
  # An openai assistant
6
6
  class Retrieve < Base
7
7
  # @param assistant_id [String] The id of assistant after create
8
- # @return [OpenaiAsissistant::Mapper::OpenaiAsissistant] A new response object of assistant.
8
+ # @return [OpenaiAssistant::Mapper::OpenaiAssistant] A new response object of assistant.
9
9
  def retrieve_assistant(assistant_id)
10
10
  url = "#{@openai_url}/#{assistant_id}"
11
11
  uri = URI(url)
12
12
  response = @http_client.call_get(uri, default_headers)
13
- return OpenaiAsissistant::ErrorResponse.from_json(response.body) unless response.code == "200"
13
+ return OpenaiAssistant::ErrorResponse.from_json(response.body) unless response.code == "200"
14
14
 
15
- OpenaiAsissistant::Mapper::Assistant.from_json(JSON.parse(response.body))
15
+ OpenaiAssistant::Mapper::Assistant.from_json(JSON.parse(response.body))
16
16
  end
17
17
  end
18
18
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module OpenaiAsissistant
3
+ module OpenaiAssistant
4
4
  # An http client
5
5
  class HTTPClient
6
6
  # disable_ssl instead of ssl because almost the host is https
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module OpenaiAsissistant
3
+ module OpenaiAssistant
4
4
  # A error response of openai
5
5
  class ErrorResponse
6
6
  # @return [String] error message
@@ -20,7 +20,7 @@ module OpenaiAsissistant
20
20
 
21
21
  def self.from_json(response_body)
22
22
  data = JSON.parse(response_body)["error"]
23
- OpenaiAsissistant::ErrorResponse.new(
23
+ OpenaiAssistant::ErrorResponse.new(
24
24
  message: data["message"],
25
25
  type: data["type"],
26
26
  param: data["param"],
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module OpenaiAsissistant
3
+ module OpenaiAssistant
4
4
  # A mapper of assistant
5
5
  module Mapper
6
6
  # A object model struct of assistant
@@ -33,7 +33,7 @@ module OpenaiAsissistant
33
33
  end
34
34
 
35
35
  def self.from_json(data)
36
- OpenaiAsissistant::Mapper::Assistant.new(
36
+ OpenaiAssistant::Mapper::Assistant.new(
37
37
  id: data["id"],
38
38
  object: data["object"],
39
39
  created_at: data["created_at"],
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module OpenaiAsissistant
4
- VERSION = "1.0.0"
3
+ module OpenaiAssistant
4
+ VERSION = "1.1.0"
5
5
  end
@@ -5,7 +5,7 @@ require_relative "lib/openai_assistant/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "openai-assistant"
8
- spec.version = OpenaiAsissistant::VERSION
8
+ spec.version = OpenaiAssistant::VERSION
9
9
  spec.authors = ["duonghds"]
10
10
  spec.email = ["duong.hoang@employmenthero.com"]
11
11
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openai-assistant
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - duonghds
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-07 00:00:00.000000000 Z
11
+ date: 2023-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec