ai_client 0.4.0 → 0.4.1

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: 72666a60d1c49346ce8512fbfe97fbc163801f5cc22e9f7ed3883c3c8e28901b
4
- data.tar.gz: bbcaee95e9ef2a6fd8bad5159ff8aa6d8cc88f443302dd37573c0bf7da512a66
3
+ metadata.gz: a6a570561363cbf57df995b7154be4214cb7e7488f0e826bd92b9d523affe52b
4
+ data.tar.gz: 42c3545fd727a240261c7df1d39528fcb5bf8c6cf6dce5820763d3cef22ccd20
5
5
  SHA512:
6
- metadata.gz: 04045a6f8a78671930429f9481e4319b36cf5955d802f8f6ae5b4ec6c4bd1b4c88d4854bcaa44fbb3b4a0f4b7d68c7a4f3d0c4045c767c590cf417efac905e5f
7
- data.tar.gz: d26f1770c0dd38d6c83fed91eca4e8489ac485415b91bb0e0d5ef0496f09af20f0e532974b984fcabedd997562494f20881966b3b5bee0e1a091013431f5e18d
6
+ metadata.gz: a20e587c840fc83a5a3253cead493b15672d64ed0994245da1f54b2fc0e74852170637ff7c2d745b1cec5776cdfc3716bd210a664667632db3700075c5b974d5
7
+ data.tar.gz: 2e25503d39cbb956905c46cea2c519d6b086a0887469bd5b7c237040063aac2c886bdd57ffca365376ad908b53f407c3ef090a731f83551452dbcb4a782105a6
data/CHANGELOG.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  ## Released
4
4
 
5
+ ### [0.4.1] - 2024-10-21
6
+ - fixed the context problem. the chatbot method works now.
7
+
5
8
  ### [0.4.0] - 2024-10-20
6
9
  - Removed Logger.new(STDOUT) from the default configuration
7
10
  > config.logger now returns nil If you want a class or instance logger setup, then you will have to do a config.logger = Logger.new(STDOUT) or whatever you need.
@@ -43,7 +43,10 @@ class AiClient
43
43
  @last_response = result
44
44
  result = raw? ? result : content
45
45
 
46
- @context.push(@last_response)
46
+ @context = @context.push({
47
+ user: @last_messages,
48
+ bot: result
49
+ }).last(config.context_length)
47
50
 
48
51
  result
49
52
  end
@@ -54,19 +57,18 @@ class AiClient
54
57
  # @param prompt [String, Array<String>] the current prompt.
55
58
  # @return [String, Array<String>] the prompt with context added.
56
59
  #
57
- def add_context(prompt)
58
- return(prompt) if @config.context_length.nil? ||
59
- 0 == @config.context_length ||
60
- prompt.is_a?(Array) ||
61
- @context.empty?
60
+ def add_context(my_prompt)
61
+ return(my_prompt) if @config.context_length.nil? ||
62
+ 0 == @config.context_length ||
63
+ my_prompt.is_a?(Array) ||
64
+ @context.empty?
62
65
 
63
-
64
- prompt << "\nUse the following context in crafting your response.\n"
65
-
66
- @context[..config.context_length].each do |result|
67
- prompt << "You previously responded with:\n"
68
- prompt << "#{raw? ? result.inspect : content(result)}"
69
- end
66
+ prompt = "\nUser: #{my_prompt} Bot: "
67
+ prompt.prepend(
68
+ @context.map{|entry|
69
+ "User: #{entry[:user]} Bot: #{entry[:bot]}"
70
+ }.join("\n")
71
+ )
70
72
 
71
73
  prompt
72
74
  end
@@ -90,4 +92,17 @@ class AiClient
90
92
  def chat_without_middlewares(messages, **params, &block)
91
93
  @client.chat(messages, model: @model, **params, &block)
92
94
  end
95
+
96
+
97
+ def chatbot
98
+ prompt = "hello"
99
+ until prompt.empty? do
100
+ response = chat prompt
101
+ puts
102
+ puts content
103
+ puts
104
+ print "Follow Up: "
105
+ prompt = gets.chomp
106
+ end
107
+ end
93
108
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class AiClient
4
- VERSION = "0.4.0"
4
+ VERSION = "0.4.1"
5
5
 
6
6
  def version = VERSION
7
7
  def self.version = VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ai_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dewayne VanHoozer