roseflow 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.standard.yml +3 -1
  3. data/CHANGELOG.md +2 -2
  4. data/Gemfile +2 -0
  5. data/examples/github-repo-chat/lib/actions/clone_and_load_repository.rb +52 -0
  6. data/examples/github-repo-chat/lib/actions/create_prompt.rb +15 -0
  7. data/examples/github-repo-chat/lib/actions/embed_repository.rb +35 -0
  8. data/examples/github-repo-chat/lib/actions/initialize_vector_store.rb +40 -0
  9. data/examples/github-repo-chat/lib/actions/interact_with_model.rb +29 -0
  10. data/examples/github-repo-chat/lib/actions/load_documents_to_database.rb +0 -0
  11. data/examples/github-repo-chat/lib/actions/split_files_to_documents.rb +55 -0
  12. data/examples/github-repo-chat/lib/document_database.rb +0 -0
  13. data/examples/github-repo-chat/lib/github_chat_prompt.rb +24 -0
  14. data/examples/github-repo-chat/lib/github_repository_chat.rb +12 -0
  15. data/examples/github-repo-chat/lib/interactions/ask_llm.rb +31 -0
  16. data/examples/github-repo-chat/lib/interactions/github_repository_chat.rb +36 -0
  17. data/examples/github-repo-chat/lib/interactions/load_files_to_document_database.rb +18 -0
  18. data/examples/github-repo-chat/lib/interactions/load_repository.rb +20 -0
  19. data/examples/github-repo-chat/lib/interactions/prepare_vector_store.rb +21 -0
  20. data/examples/github-repo-chat/lib/repository.rb +9 -0
  21. data/examples/github-repo-chat/lib/repository_file.rb +31 -0
  22. data/examples/github-repo-chat/spec/actions/clone_and_load_repository_spec.rb +28 -0
  23. data/examples/github-repo-chat/spec/actions/embed_repository_spec.rb +24 -0
  24. data/examples/github-repo-chat/spec/actions/initialize_vector_store_spec.rb +20 -0
  25. data/examples/github-repo-chat/spec/actions/load_files_to_document_database_spec.rb +23 -0
  26. data/examples/github-repo-chat/spec/fixtures/ulid-ruby.zip +0 -0
  27. data/examples/github-repo-chat/spec/github_repository_chat_spec.rb +16 -0
  28. data/examples/github-repo-chat/spec/interactions/prepare_vector_store_spec.rb +4 -0
  29. data/examples/github-repo-chat/spec/spec_helper.rb +12 -0
  30. data/lib/roseflow/action.rb +13 -0
  31. data/lib/roseflow/actions/ai/resolve_model.rb +27 -0
  32. data/lib/roseflow/actions/ai/resolve_provider.rb +31 -0
  33. data/lib/roseflow/ai/model.rb +19 -0
  34. data/lib/roseflow/ai/provider.rb +30 -0
  35. data/lib/roseflow/chat/dialogue.rb +80 -0
  36. data/lib/roseflow/chat/exchange.rb +12 -0
  37. data/lib/roseflow/chat/message.rb +39 -0
  38. data/lib/roseflow/chat/personality.rb +10 -0
  39. data/lib/roseflow/embeddings/embedding.rb +26 -0
  40. data/lib/roseflow/finite_machine.rb +298 -0
  41. data/lib/roseflow/interaction/with_http_api.rb +10 -0
  42. data/lib/roseflow/interaction.rb +14 -0
  43. data/lib/roseflow/interaction_context.rb +10 -0
  44. data/lib/roseflow/interactions/ai/initialize_llm.rb +26 -0
  45. data/lib/roseflow/primitives/vector.rb +19 -0
  46. data/lib/roseflow/prompt.rb +17 -0
  47. data/lib/roseflow/text/completion.rb +16 -0
  48. data/lib/roseflow/text/recursive_character_splitter.rb +43 -0
  49. data/lib/roseflow/text/sentence_splitter.rb +42 -0
  50. data/lib/roseflow/text/splitter.rb +18 -0
  51. data/lib/roseflow/text/tokenized_text.rb +20 -0
  52. data/lib/roseflow/text/word_splitter.rb +14 -0
  53. data/lib/roseflow/tokenizer.rb +13 -0
  54. data/lib/roseflow/types.rb +9 -0
  55. data/lib/roseflow/vector_stores/base.rb +39 -0
  56. data/lib/roseflow/vector_stores/hnsw.proto +18 -0
  57. data/lib/roseflow/vector_stores/hnsw_memory_store.rb +442 -0
  58. data/lib/roseflow/vector_stores/hnsw_pb.rb +27 -0
  59. data/lib/roseflow/vector_stores/type/vector.rb +38 -0
  60. data/lib/roseflow/vector_stores/vector.rb +19 -0
  61. data/lib/roseflow/version.rb +12 -1
  62. data/lib/roseflow.rb +10 -1
  63. data/roseflow.gemspec +53 -0
  64. metadata +274 -7
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_model/type"
4
+
5
+ module Roseflow
6
+ module VectorStores
7
+ module Type
8
+ class Vector < ActiveModel::Type::Value
9
+ def initialize(dimensions:, model:, attribute_name:)
10
+ super()
11
+ @dimensions = dimensions
12
+ @model = model
13
+ @attribute_name = attribute_name
14
+ end
15
+
16
+ def self.cast(value, dimensions:)
17
+ value = value.to_a.map(&:to_f)
18
+
19
+ raise Error, "Values must be finite" unless value.all?(&:finite?)
20
+
21
+ value
22
+ end
23
+
24
+ def cast(value)
25
+ self.class.cast(value, dimensions: @dimensions) unless value.nil?
26
+ end
27
+
28
+ def serialize(value)
29
+ raise NotImplementedError
30
+ end
31
+
32
+ def deserialize(value)
33
+ raise NotImplementedError
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry-types"
4
+
5
+ module Types
6
+ include Dry.Types()
7
+ Number = Types::Float | Types::Integer
8
+ end
9
+
10
+ module Roseflow
11
+ module VectorStores
12
+ class Vector < Dry::Struct
13
+ transform_keys(&:to_sym)
14
+
15
+ attribute :values, Types::Array.of(Types::Number)
16
+ attribute :dimensions, Types::Integer
17
+ end # Vector
18
+ end # VectorStores
19
+ end # Roseflow
@@ -1,5 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Roseflow
4
- VERSION = "0.0.1"
4
+ def self.gem_version
5
+ Gem::Version.new VERSION::STRING
6
+ end
7
+
8
+ module VERSION
9
+ MAJOR = 0
10
+ MINOR = 1
11
+ PATCH = 0
12
+ PRE = nil
13
+
14
+ STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
15
+ end
5
16
  end
data/lib/roseflow.rb CHANGED
@@ -2,8 +2,17 @@
2
2
 
3
3
  require_relative "roseflow/version"
4
4
 
5
+ require "roseflow/action"
6
+ require "roseflow/ai/model"
7
+ require "roseflow/ai/provider"
8
+ require "roseflow/finite_machine"
9
+ require "roseflow/interaction"
10
+ require "roseflow/interaction_context"
11
+ require "roseflow/interactions/ai/initialize_llm"
12
+ require "roseflow/vector_stores/base"
13
+
5
14
  module Roseflow
6
15
  class Error < StandardError; end
7
-
16
+
8
17
  # Releasing the Kraken soon...
9
18
  end
data/roseflow.gemspec ADDED
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/roseflow/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "roseflow"
7
+ spec.version = Roseflow.gem_version
8
+ spec.authors = ["Lauri Jutila"]
9
+ spec.email = ["github@laurijutila.com"]
10
+
11
+ spec.description = "Roseflow is a library for effortlessly building interactions with AI"
12
+ spec.homepage = "https://github.com/roseflow-ai/roseflow"
13
+
14
+ spec.summary = "Effortless interactions with AI"
15
+ spec.license = "MIT"
16
+
17
+ spec.required_ruby_version = ">= 3.2.0"
18
+
19
+ # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = "https://github.com/roseflow-ai/roseflow"
23
+ spec.metadata["changelog_uri"] = "https://github.com/roseflow-ai/roseflow/blob/master/CHANGELOG.md"
24
+
25
+ # Specify which files should be added to the gem when it is released.
26
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
+ spec.files = Dir.chdir(__dir__) do
28
+ `git ls-files -z`.split("\x0").reject do |f|
29
+ (File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
30
+ end
31
+ end
32
+ spec.bindir = "exe"
33
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
34
+ spec.require_paths = ["lib"]
35
+
36
+ # Uncomment to register a new dependency of your gem
37
+ spec.add_dependency "activesupport", "~> 7.0"
38
+ spec.add_dependency "activemodel", "~> 7.0"
39
+ spec.add_dependency "anyway_config", "~> 2.0"
40
+ spec.add_dependency "dry-struct", "~> 1.6"
41
+ spec.add_dependency "dry-validation", "~> 1.10"
42
+ spec.add_dependency "finite_machine", "~> 0.14"
43
+ spec.add_dependency "hashie", "~> 5.0"
44
+ spec.add_dependency "light-service", "~> 0.18"
45
+ spec.add_dependency "phlex", "~> 1.8.1"
46
+ spec.add_dependency "ulid-ruby", "~> 1.0"
47
+
48
+ spec.add_development_dependency "pragmatic_segmenter", "~> 0.3"
49
+ spec.add_development_dependency "roseflow-openai", "~> 0.1.0"
50
+ spec.add_development_dependency "roseflow-pinecone", "~> 0.1.0"
51
+ spec.add_development_dependency "webmock"
52
+ spec.add_development_dependency "vcr"
53
+ end
metadata CHANGED
@@ -1,15 +1,225 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roseflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lauri Jutila
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-22 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2023-05-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '7.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '7.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activemodel
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '7.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '7.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: anyway_config
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: dry-struct
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.6'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: dry-validation
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.10'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.10'
83
+ - !ruby/object:Gem::Dependency
84
+ name: finite_machine
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.14'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.14'
97
+ - !ruby/object:Gem::Dependency
98
+ name: hashie
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '5.0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '5.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: light-service
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.18'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.18'
125
+ - !ruby/object:Gem::Dependency
126
+ name: phlex
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 1.8.1
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 1.8.1
139
+ - !ruby/object:Gem::Dependency
140
+ name: ulid-ruby
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1.0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '1.0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: pragmatic_segmenter
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.3'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.3'
167
+ - !ruby/object:Gem::Dependency
168
+ name: roseflow-openai
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: 0.1.0
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 0.1.0
181
+ - !ruby/object:Gem::Dependency
182
+ name: roseflow-pinecone
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: 0.1.0
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: 0.1.0
195
+ - !ruby/object:Gem::Dependency
196
+ name: webmock
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: vcr
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
13
223
  description: Roseflow is a library for effortlessly building interactions with AI
14
224
  email:
15
225
  - github@laurijutila.com
@@ -25,16 +235,73 @@ files:
25
235
  - LICENSE.txt
26
236
  - README.md
27
237
  - Rakefile
238
+ - examples/github-repo-chat/lib/actions/clone_and_load_repository.rb
239
+ - examples/github-repo-chat/lib/actions/create_prompt.rb
240
+ - examples/github-repo-chat/lib/actions/embed_repository.rb
241
+ - examples/github-repo-chat/lib/actions/initialize_vector_store.rb
242
+ - examples/github-repo-chat/lib/actions/interact_with_model.rb
243
+ - examples/github-repo-chat/lib/actions/load_documents_to_database.rb
244
+ - examples/github-repo-chat/lib/actions/split_files_to_documents.rb
245
+ - examples/github-repo-chat/lib/document_database.rb
246
+ - examples/github-repo-chat/lib/github_chat_prompt.rb
247
+ - examples/github-repo-chat/lib/github_repository_chat.rb
248
+ - examples/github-repo-chat/lib/interactions/ask_llm.rb
249
+ - examples/github-repo-chat/lib/interactions/github_repository_chat.rb
250
+ - examples/github-repo-chat/lib/interactions/load_files_to_document_database.rb
251
+ - examples/github-repo-chat/lib/interactions/load_repository.rb
252
+ - examples/github-repo-chat/lib/interactions/prepare_vector_store.rb
253
+ - examples/github-repo-chat/lib/repository.rb
254
+ - examples/github-repo-chat/lib/repository_file.rb
255
+ - examples/github-repo-chat/spec/actions/clone_and_load_repository_spec.rb
256
+ - examples/github-repo-chat/spec/actions/embed_repository_spec.rb
257
+ - examples/github-repo-chat/spec/actions/initialize_vector_store_spec.rb
258
+ - examples/github-repo-chat/spec/actions/load_files_to_document_database_spec.rb
259
+ - examples/github-repo-chat/spec/fixtures/ulid-ruby.zip
260
+ - examples/github-repo-chat/spec/github_repository_chat_spec.rb
261
+ - examples/github-repo-chat/spec/interactions/prepare_vector_store_spec.rb
262
+ - examples/github-repo-chat/spec/spec_helper.rb
28
263
  - lib/roseflow.rb
264
+ - lib/roseflow/action.rb
265
+ - lib/roseflow/actions/ai/resolve_model.rb
266
+ - lib/roseflow/actions/ai/resolve_provider.rb
267
+ - lib/roseflow/ai/model.rb
268
+ - lib/roseflow/ai/provider.rb
269
+ - lib/roseflow/chat/dialogue.rb
270
+ - lib/roseflow/chat/exchange.rb
271
+ - lib/roseflow/chat/message.rb
272
+ - lib/roseflow/chat/personality.rb
273
+ - lib/roseflow/embeddings/embedding.rb
274
+ - lib/roseflow/finite_machine.rb
275
+ - lib/roseflow/interaction.rb
276
+ - lib/roseflow/interaction/with_http_api.rb
277
+ - lib/roseflow/interaction_context.rb
278
+ - lib/roseflow/interactions/ai/initialize_llm.rb
279
+ - lib/roseflow/primitives/vector.rb
280
+ - lib/roseflow/prompt.rb
281
+ - lib/roseflow/text/completion.rb
282
+ - lib/roseflow/text/recursive_character_splitter.rb
283
+ - lib/roseflow/text/sentence_splitter.rb
284
+ - lib/roseflow/text/splitter.rb
285
+ - lib/roseflow/text/tokenized_text.rb
286
+ - lib/roseflow/text/word_splitter.rb
287
+ - lib/roseflow/tokenizer.rb
288
+ - lib/roseflow/types.rb
289
+ - lib/roseflow/vector_stores/base.rb
290
+ - lib/roseflow/vector_stores/hnsw.proto
291
+ - lib/roseflow/vector_stores/hnsw_memory_store.rb
292
+ - lib/roseflow/vector_stores/hnsw_pb.rb
293
+ - lib/roseflow/vector_stores/type/vector.rb
294
+ - lib/roseflow/vector_stores/vector.rb
29
295
  - lib/roseflow/version.rb
296
+ - roseflow.gemspec
30
297
  - sig/roseflow.rbs
31
- homepage: https://github.com/ljuti/roseflow
298
+ homepage: https://github.com/roseflow-ai/roseflow
32
299
  licenses:
33
300
  - MIT
34
301
  metadata:
35
- homepage_uri: https://github.com/ljuti/roseflow
36
- source_code_uri: https://github.com/ljuti/roseflow
37
- changelog_uri: https://github.com/ljuti/roseflow/blob/master/CHANGELOG.md
302
+ homepage_uri: https://github.com/roseflow-ai/roseflow
303
+ source_code_uri: https://github.com/roseflow-ai/roseflow
304
+ changelog_uri: https://github.com/roseflow-ai/roseflow/blob/master/CHANGELOG.md
38
305
  post_install_message:
39
306
  rdoc_options: []
40
307
  require_paths: