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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -2
- data/lib/active_pinecone/assistant.rb +4 -3
- data/lib/active_pinecone/base.rb +2 -2
- data/lib/active_pinecone/version.rb +1 -1
- metadata +2 -3
- data/CHANGELOG.md +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38ef74e28c153ccc5f1be852b0ae2fa4335f8b89f82f5881024cfcac15d90651
|
4
|
+
data.tar.gz: a3d0195f33146030f6b22cf2e3397f26ed898d37fb5f922a2854f69960bd2e54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7315e73367aefcca19a0d3447c23d244453720006309f4fd4250b550f423b50624075c6f02fc0203b495f7afec3b541a4d95f3d933c8875f770058dc61c2c044
|
7
|
+
data.tar.gz: b03841435b593142c0468b021d56e49377ecff539b84537f1bc254c2b1120075c614a1fdddd920e6f64bbe8f3cb899969e17ab7e855a13d39c0f238ef9dc8935
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -33,7 +33,7 @@ Define a model.
|
|
33
33
|
|
34
34
|
```ruby
|
35
35
|
class Recipe < ActivePinecone::Base
|
36
|
-
|
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] =
|
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 }
|
data/lib/active_pinecone/base.rb
CHANGED
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.
|
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-
|
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
|