active_pinecone 0.1.2 → 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: dbb4bdb69aaf9aa85766c319037b9311723cee547225ac50164d1bbb901f4088
4
- data.tar.gz: bbfb0850459a29ede430701eae8eb84df648fbc513f11cd8cdc96a5dd9d2fe80
3
+ metadata.gz: 0ee5de085e7ff280125a077b337f5c9bf7ad774a3f609bb8d56cf8f79a70104d
4
+ data.tar.gz: 9dc48681b7b3ea98950d0cb56461f805bf102c32e199bfe5a8e9af149c9284d4
5
5
  SHA512:
6
- metadata.gz: 0b45d3d4a9e9901517cab3dbcb2d6c7a621be06975df0912272889b159efda5086faaf313d9de82dbf15bf89b81bdc158fac3310019420b30df98c6a9bdb994c
7
- data.tar.gz: b161770f5712b5d6f43e99ce85285e298bf1efc73344c5321f2ba384bcecd5745c45620224befc604d8531700966bb7c245d4fccd7ccad13bd8c418be77e586a
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.2)
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
@@ -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.2'
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.2
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,14 +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
11
-
12
- ## [0.1.2] - 2023-05-24
13
-
14
- - Fix README