chat_gpt_client 0.1.0 → 0.2.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: f7641c9f199e34018c618fda5d669b58a6ca5ae5c727d72aebe1587beb0d7b82
4
- data.tar.gz: ad2f1f30e8b3b766310d403646e872f38bdbd823d9110abc15d6cdcea95d32e5
3
+ metadata.gz: 63a9663535742a12f4720e60dfac2589c7cfcf02ffe9c63813aa06cb7b9335e2
4
+ data.tar.gz: 6a1d4649a5ef6ba7ed711f1ba15f905e8b24e913f1224360d3070c2a372ac1c9
5
5
  SHA512:
6
- metadata.gz: 2bd0344f4af641f8fc9d96c8d771df55e9eb7852365c7a8b559e6ab4dfc70f8a9fcd9daf5f8881652753afb1a0bc9ea6495c14e72808312e5fd97686687d691c
7
- data.tar.gz: f570d3e7f136eb8e7725e1f1b4ab80d431faddd550526e1ba67ddc782d3af2a169a7bf3775f6fc99fa6bb3dfe12fed65a4cb84f56530600c59ca25e5e66e2401
6
+ metadata.gz: 6f7331daaa81a07cef793599a7026f4b73898574dde43fd60cc6f69b553b7102fda812fed5a78567ec9100c26a1dff4df4794c5e7cdbe889bf06b8b5eb7428a7
7
+ data.tar.gz: 3bbb94c0d72d0f9fbf5c83794a827c7470c6fc31e9ca83f0615274388511e070093c834b5668ecffee1272e0d8157985026ae19ed1186c81fc41de5950c699af
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chat_gpt_client (0.1.0)
4
+ chat_gpt_client (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -44,6 +44,7 @@ GEM
44
44
 
45
45
  PLATFORMS
46
46
  x86_64-darwin-21
47
+ x86_64-linux
47
48
 
48
49
  DEPENDENCIES
49
50
  chat_gpt_client!
@@ -3,13 +3,14 @@
3
3
  module ChatGPT
4
4
  # The client for the OpenAI ChatGPT API
5
5
  class Client
6
- def initialize(api_key: ENV["OPENAI_API_KEY"], system_prompt: nil)
6
+ def initialize(api_key: ENV["OPENAI_API_KEY"], system_prompt: nil, temperature: nil)
7
7
  if api_key.nil? || api_key.empty?
8
- raise Error, "You must provide an API token or set the OPENAI_API_KEY environment variable"
8
+ raise ChatGPT::Error, "You must provide an API token or set the OPENAI_API_KEY environment variable"
9
9
  end
10
10
 
11
11
  @api_key = api_key
12
12
  @system_prompt = system_prompt
13
+ @temperature = temperature
13
14
  @history = []
14
15
  end
15
16
 
@@ -58,7 +59,7 @@ module ChatGPT
58
59
  end
59
60
 
60
61
  def extract_response(response)
61
- raise Error, "Error: #{response.code} - #{response.body}" unless response.code == "200"
62
+ raise ChatGPT::Error, "Error: #{response.code} - #{response.body}" unless response.code == "200"
62
63
 
63
64
  JSON.parse(response.body)
64
65
  end
@@ -66,7 +67,8 @@ module ChatGPT
66
67
  def build_body
67
68
  {
68
69
  model: "gpt-3.5-turbo",
69
- messages: history
70
+ messages: history,
71
+ temperature: @temperature
70
72
  }
71
73
  end
72
74
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ChatGPT
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chat_gpt_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francesco Boffa