active_pinecone 0.1.2 → 0.1.4

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: 38ef74e28c153ccc5f1be852b0ae2fa4335f8b89f82f5881024cfcac15d90651
4
+ data.tar.gz: a3d0195f33146030f6b22cf2e3397f26ed898d37fb5f922a2854f69960bd2e54
5
5
  SHA512:
6
- metadata.gz: 0b45d3d4a9e9901517cab3dbcb2d6c7a621be06975df0912272889b159efda5086faaf313d9de82dbf15bf89b81bdc158fac3310019420b30df98c6a9bdb994c
7
- data.tar.gz: b161770f5712b5d6f43e99ce85285e298bf1efc73344c5321f2ba384bcecd5745c45620224befc604d8531700966bb7c245d4fccd7ccad13bd8c418be77e586a
6
+ metadata.gz: 7315e73367aefcca19a0d3447c23d244453720006309f4fd4250b550f423b50624075c6f02fc0203b495f7afec3b541a4d95f3d933c8875f770058dc61c2c044
7
+ data.tar.gz: b03841435b593142c0468b021d56e49377ecff539b84537f1bc254c2b1120075c614a1fdddd920e6f64bbe8f3cb899969e17ab7e855a13d39c0f238ef9dc8935
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.4)
5
5
  activesupport (>= 5.0.0)
6
6
  pinecone (~> 0.1.5)
7
7
  ruby-openai (~> 4.1.0)
data/README.md CHANGED
@@ -33,7 +33,7 @@ Define a model.
33
33
 
34
34
  ```ruby
35
35
  class Recipe < ActivePinecone::Base
36
- vectorize :title, :body
36
+ vectorizes :title, :body
37
37
  end
38
38
  ```
39
39
 
@@ -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.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moeki Kawakami
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-24 00:00:00.000000000 Z
11
+ date: 2023-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -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