active_pinecone 0.1.1 → 0.1.3

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: ac83a40bff569558fe83e8b92eef9f9f81fc152a92f69a101dfde763f633c108
4
- data.tar.gz: 0cf15188e17fae9e367024c4197168f3620205fe24719ab095c41a150cca6176
3
+ metadata.gz: 0ee5de085e7ff280125a077b337f5c9bf7ad774a3f609bb8d56cf8f79a70104d
4
+ data.tar.gz: 9dc48681b7b3ea98950d0cb56461f805bf102c32e199bfe5a8e9af149c9284d4
5
5
  SHA512:
6
- metadata.gz: efafb2f1c7a68b2e4fa3a9f08668038595f126cbf41f191e929f2645cb413968e0c6786681fe5d65298dcf5b3efda20b876875fd6ce889a51c546c71f6ddf8e2
7
- data.tar.gz: c01271f4b41521e3a259666c8937c60dd16a204ea663fd3fa4a73b0fc87a1fa90d75dad941ff251e5fd84097b3a7597b168b6c99555499d302f7de321f5c65d0
6
+ metadata.gz: 92c38c0c0170ac5abac13aa0492cf067c9b27da234d79fe763dc3f4039dfb4e4d5c842ab5b98965fc8c338a0572a3eedf134e79337c17daedb0d8811462dc573
7
+ data.tar.gz: 4ff83a4e9c148212ead0546b322231ee84ba22f8690fd2a5c95a1e11b7836225523bbf71924e01c9a66e844f2f576cfad02bb1326040f3d50fc1a10559a79cb2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_pinecone (0.1.1)
4
+ active_pinecone (0.1.3)
5
5
  activesupport (>= 5.0.0)
6
6
  pinecone (~> 0.1.5)
7
7
  ruby-openai (~> 4.1.0)
data/README.md CHANGED
@@ -42,7 +42,7 @@ end
42
42
  Create Pinecone index. Index initialization takes a few minutes.
43
43
 
44
44
  ```ruby
45
- Post.init
45
+ Recipe.init
46
46
  ```
47
47
 
48
48
 
@@ -85,7 +85,10 @@ p recipes.first.title
85
85
  Assistant search vector data by **ALL** conversation history and reply.
86
86
 
87
87
  ```ruby
88
- assistant = Recipe.assistant
88
+ assistant = Recipe.assistant([
89
+ "You are the assistant who answers the user's questions about the recipe.",
90
+ "The list of recipes is as follows:"
91
+ ].join("\n"))
89
92
 
90
93
  reply = assistant.reply("How to make a hamburger?")
91
94
 
@@ -1,9 +1,10 @@
1
1
  module ActivePinecone
2
2
  class Assistant
3
- attr_reader :model
3
+ attr_reader :model, :instruction
4
4
 
5
- def initialize(model)
5
+ def initialize(model, instruction: 'Context:')
6
6
  @model = model
7
+ @instruction = instruction
7
8
  @messages_with_system = [{ role: 'system', content: '' }]
8
9
  end
9
10
 
@@ -20,7 +21,7 @@ module ActivePinecone
20
21
 
21
22
  records = model.search(messages.pluck(:content))
22
23
 
23
- @messages_with_system[0][:content] = "Context: #{records.map(&:attributes).to_json}"
24
+ @messages_with_system[0][:content] = [instruction, records.map(&:attributes).to_json].join("\n")
24
25
 
25
26
  result = self.class.openai.chat(
26
27
  parameters: { model: ActivePinecone.configuration.chat_model, messages: messages, temperature: 0.7 }
@@ -12,8 +12,8 @@ module ActivePinecone
12
12
  end
13
13
  end
14
14
 
15
- def self.assistant
16
- ActivePinecone::Assistant.new(self)
15
+ def self.assistant(instruction = 'Context:')
16
+ ActivePinecone::Assistant.new(self, instruction: instruction)
17
17
  end
18
18
 
19
19
  def self.index_name
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActivePinecone
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_pinecone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moeki Kawakami
@@ -60,7 +60,6 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - ".rspec"
63
- - CHANGELOG.md
64
63
  - CODE_OF_CONDUCT.md
65
64
  - Gemfile
66
65
  - Gemfile.lock
data/CHANGELOG.md DELETED
@@ -1,10 +0,0 @@
1
- ## [Unreleased]
2
-
3
- ## [0.1.0] - 2023-06-24
4
-
5
- - Initial release
6
-
7
- ## [0.1.1] - 2023-05-24
8
-
9
- - Bug fix
10
- - Add example