prescient 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.env.example +37 -0
- data/.rubocop.yml +326 -0
- data/Dockerfile.example +41 -0
- data/README.md +859 -13
- data/Rakefile +25 -3
- data/VECTOR_SEARCH_GUIDE.md +450 -0
- data/db/init/01_enable_pgvector.sql +30 -0
- data/db/init/02_create_schema.sql +108 -0
- data/db/init/03_create_indexes.sql +96 -0
- data/db/init/04_insert_sample_data.sql +121 -0
- data/db/migrate/001_create_prescient_tables.rb +158 -0
- data/docker-compose.yml +153 -0
- data/examples/basic_usage.rb +123 -0
- data/examples/custom_contexts.rb +355 -0
- data/examples/custom_prompts.rb +212 -0
- data/examples/vector_search.rb +330 -0
- data/lib/prescient/base.rb +270 -0
- data/lib/prescient/client.rb +107 -0
- data/lib/prescient/provider/anthropic.rb +146 -0
- data/lib/prescient/provider/huggingface.rb +202 -0
- data/lib/prescient/provider/ollama.rb +172 -0
- data/lib/prescient/provider/openai.rb +181 -0
- data/lib/prescient/version.rb +1 -1
- data/lib/prescient.rb +84 -2
- data/prescient.gemspec +51 -0
- data/scripts/setup-ollama-models.sh +77 -0
- metadata +215 -12
- data/.vscode/settings.json +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62c70c521da514a785f44beb284287d56a3affd451160bcc8bcad26fff713303
|
4
|
+
data.tar.gz: 4b7a41690ae8395cb57ccefee607764d850256d6fe9c4341db038e28ee67c7ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cff60610144acef5b2be9693dbe87f1bb7b231dae219ac5cc826c2720fb383ed7c6df580cfe9a9ac26eb56812bc841178d605272adde63054506006cfdd9575
|
7
|
+
data.tar.gz: c6f3eef2edcd1f53eb0c41a779db4b4aae36990e40b91ff406077353fd8c9d3b10332c2c5701a17ba88c3fb2debec6eb4e8560eb14a9c483e387dc146d5f6b18
|
data/.env.example
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Example environment configuration for Prescient gem
|
2
|
+
# Copy this file to .env and configure your API keys
|
3
|
+
|
4
|
+
# Ollama Configuration (Local AI)
|
5
|
+
OLLAMA_URL=http://localhost:11434
|
6
|
+
OLLAMA_EMBEDDING_MODEL=nomic-embed-text
|
7
|
+
OLLAMA_CHAT_MODEL=llama3.1:8b
|
8
|
+
|
9
|
+
# OpenAI Configuration
|
10
|
+
OPENAI_API_KEY=your_openai_api_key_here
|
11
|
+
OPENAI_EMBEDDING_MODEL=text-embedding-3-small
|
12
|
+
OPENAI_CHAT_MODEL=gpt-3.5-turbo
|
13
|
+
|
14
|
+
# Anthropic Configuration
|
15
|
+
ANTHROPIC_API_KEY=your_anthropic_api_key_here
|
16
|
+
ANTHROPIC_MODEL=claude-3-haiku-20240307
|
17
|
+
|
18
|
+
# HuggingFace Configuration
|
19
|
+
HUGGINGFACE_API_KEY=your_huggingface_api_key_here
|
20
|
+
HUGGINGFACE_EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2
|
21
|
+
HUGGINGFACE_CHAT_MODEL=microsoft/DialoGPT-medium
|
22
|
+
|
23
|
+
# PostgreSQL with pgvector Configuration
|
24
|
+
DB_HOST=localhost
|
25
|
+
DB_PORT=5432
|
26
|
+
DB_NAME=prescient_development
|
27
|
+
DB_USER=prescient
|
28
|
+
DB_PASSWORD=prescient_password
|
29
|
+
|
30
|
+
# Optional: Redis for caching (if using with Docker)
|
31
|
+
REDIS_URL=redis://localhost:6379/0
|
32
|
+
|
33
|
+
# Application Configuration
|
34
|
+
PRESCIENT_DEFAULT_PROVIDER=ollama
|
35
|
+
PRESCIENT_TIMEOUT=60
|
36
|
+
PRESCIENT_RETRY_ATTEMPTS=3
|
37
|
+
PRESCIENT_RETRY_DELAY=1.0
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,326 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# RuboCop configuration for Prescient gem
|
4
|
+
# Modern Ruby best practices with sensible defaults
|
5
|
+
|
6
|
+
plugins:
|
7
|
+
- rubocop-minitest
|
8
|
+
- rubocop-performance
|
9
|
+
- rubocop-rake
|
10
|
+
|
11
|
+
AllCops:
|
12
|
+
# Target Ruby 3.0+ (matches gemspec requirement)
|
13
|
+
TargetRubyVersion: 3.0
|
14
|
+
|
15
|
+
# Use new cops by default
|
16
|
+
NewCops: enable
|
17
|
+
|
18
|
+
# Exclude common directories
|
19
|
+
Exclude:
|
20
|
+
- 'vendor/**/*'
|
21
|
+
- 'bin/*'
|
22
|
+
- 'tmp/**/*'
|
23
|
+
- 'coverage/**/*'
|
24
|
+
- 'pkg/**/*'
|
25
|
+
- '*.gemspec'
|
26
|
+
- 'Gemfile'
|
27
|
+
- 'Rakefile'
|
28
|
+
- 'examples/**/*'
|
29
|
+
|
30
|
+
# === LAYOUT & FORMATTING ===
|
31
|
+
|
32
|
+
Layout/LineLength:
|
33
|
+
Max: 120
|
34
|
+
Exclude:
|
35
|
+
- 'test/**/*'
|
36
|
+
- 'lib/prescient.rb' # Configuration can have long lines
|
37
|
+
AllowedPatterns:
|
38
|
+
- '^\s*#' # Comments
|
39
|
+
- '^\s*it\s' # Test descriptions
|
40
|
+
- '^\s*context\s' # Test contexts
|
41
|
+
- '^\s*describe\s' # Test descriptions
|
42
|
+
|
43
|
+
Layout/MultilineMethodCallIndentation:
|
44
|
+
EnforcedStyle: indented
|
45
|
+
|
46
|
+
Layout/FirstHashElementIndentation:
|
47
|
+
EnforcedStyle: consistent
|
48
|
+
|
49
|
+
Layout/FirstArrayElementIndentation:
|
50
|
+
EnforcedStyle: consistent
|
51
|
+
|
52
|
+
Layout/HashAlignment:
|
53
|
+
EnforcedHashRocketStyle: table
|
54
|
+
EnforcedColonStyle: table
|
55
|
+
|
56
|
+
Layout/SpaceInsideHashLiteralBraces:
|
57
|
+
EnforcedStyle: space
|
58
|
+
|
59
|
+
Layout/EmptyLinesAroundModuleBody:
|
60
|
+
Enabled: false
|
61
|
+
|
62
|
+
Layout/EmptyLinesAroundClassBody:
|
63
|
+
Enabled: false
|
64
|
+
|
65
|
+
# === STYLE ===
|
66
|
+
|
67
|
+
Style/StringLiterals:
|
68
|
+
EnforcedStyle: single_quotes
|
69
|
+
|
70
|
+
Style/StringLiteralsInInterpolation:
|
71
|
+
EnforcedStyle: single_quotes
|
72
|
+
|
73
|
+
Style/FrozenStringLiteralComment:
|
74
|
+
Enabled: true
|
75
|
+
EnforcedStyle: always
|
76
|
+
Exclude:
|
77
|
+
- 'examples/**/*'
|
78
|
+
|
79
|
+
Style/Documentation:
|
80
|
+
Enabled: false
|
81
|
+
|
82
|
+
Style/ClassAndModuleChildren:
|
83
|
+
EnforcedStyle: compact
|
84
|
+
|
85
|
+
Style/TrailingCommaInArguments:
|
86
|
+
EnforcedStyleForMultiline: comma
|
87
|
+
|
88
|
+
Style/TrailingCommaInArrayLiteral:
|
89
|
+
EnforcedStyleForMultiline: comma
|
90
|
+
|
91
|
+
Style/TrailingCommaInHashLiteral:
|
92
|
+
EnforcedStyleForMultiline: comma
|
93
|
+
|
94
|
+
Style/HashSyntax:
|
95
|
+
EnforcedStyle: ruby19_no_mixed_keys
|
96
|
+
|
97
|
+
Style/Lambda:
|
98
|
+
EnforcedStyle: literal
|
99
|
+
|
100
|
+
Style/NumericLiterals:
|
101
|
+
MinDigits: 6
|
102
|
+
|
103
|
+
Style/BlockDelimiters:
|
104
|
+
EnforcedStyle: semantic
|
105
|
+
AllowedMethods:
|
106
|
+
- expect
|
107
|
+
- let
|
108
|
+
- subject
|
109
|
+
|
110
|
+
Style/WordArray:
|
111
|
+
EnforcedStyle: brackets
|
112
|
+
|
113
|
+
Style/SymbolArray:
|
114
|
+
EnforcedStyle: brackets
|
115
|
+
|
116
|
+
Style/FormatString:
|
117
|
+
EnforcedStyle: percent
|
118
|
+
|
119
|
+
Style/CollectionMethods:
|
120
|
+
PreferredMethods:
|
121
|
+
collect: map
|
122
|
+
collect!: map!
|
123
|
+
detect: find
|
124
|
+
find_all: select
|
125
|
+
reduce: inject
|
126
|
+
|
127
|
+
Style/Alias:
|
128
|
+
EnforcedStyle: prefer_alias_method
|
129
|
+
|
130
|
+
Style/AccessorGrouping:
|
131
|
+
EnforcedStyle: separated
|
132
|
+
|
133
|
+
Style/BisectedAttrAccessor:
|
134
|
+
Enabled: true
|
135
|
+
|
136
|
+
Style/RedundantAssignment:
|
137
|
+
Enabled: true
|
138
|
+
|
139
|
+
Style/RedundantFetchBlock:
|
140
|
+
Enabled: true
|
141
|
+
|
142
|
+
Style/RedundantFileExtensionInRequire:
|
143
|
+
Enabled: true
|
144
|
+
|
145
|
+
Style/RedundantRegexpCharacterClass:
|
146
|
+
Enabled: true
|
147
|
+
|
148
|
+
Style/RedundantRegexpEscape:
|
149
|
+
Enabled: true
|
150
|
+
|
151
|
+
Style/SlicingWithRange:
|
152
|
+
Enabled: true
|
153
|
+
|
154
|
+
Style/ExponentialNotation:
|
155
|
+
Enabled: true
|
156
|
+
|
157
|
+
Style/HashTransformKeys:
|
158
|
+
Enabled: true
|
159
|
+
|
160
|
+
Style/HashTransformValues:
|
161
|
+
Enabled: true
|
162
|
+
|
163
|
+
Style/RedundantReturn:
|
164
|
+
AllowMultipleReturnValues: true
|
165
|
+
|
166
|
+
# === METRICS ===
|
167
|
+
|
168
|
+
Metrics/ModuleLength:
|
169
|
+
Max: 150
|
170
|
+
|
171
|
+
Metrics/ClassLength:
|
172
|
+
Max: 150
|
173
|
+
Exclude:
|
174
|
+
- 'test/**/*'
|
175
|
+
|
176
|
+
Metrics/MethodLength:
|
177
|
+
Max: 25
|
178
|
+
Exclude:
|
179
|
+
- 'test/**/*'
|
180
|
+
- 'db/**/*'
|
181
|
+
- 'lib/prescient/provider/*.rb'
|
182
|
+
|
183
|
+
Metrics/BlockLength:
|
184
|
+
Max: 25
|
185
|
+
Exclude:
|
186
|
+
- 'test/**/*'
|
187
|
+
- 'lib/prescient.rb' # Configuration block
|
188
|
+
|
189
|
+
Metrics/AbcSize:
|
190
|
+
Max: 20
|
191
|
+
Exclude:
|
192
|
+
- 'test/**/*'
|
193
|
+
- 'db/**/*'
|
194
|
+
- 'lib/prescient/provider/*.rb'
|
195
|
+
|
196
|
+
Metrics/CyclomaticComplexity:
|
197
|
+
Max: 8
|
198
|
+
Exclude:
|
199
|
+
- 'lib/prescient/provider/*.rb'
|
200
|
+
|
201
|
+
Metrics/PerceivedComplexity:
|
202
|
+
Max: 8
|
203
|
+
Exclude:
|
204
|
+
- 'lib/prescient/provider/*.rb'
|
205
|
+
|
206
|
+
Metrics/ParameterLists:
|
207
|
+
Max: 5
|
208
|
+
CountKeywordArgs: false
|
209
|
+
|
210
|
+
# === LINT ===
|
211
|
+
|
212
|
+
Lint/RaiseException:
|
213
|
+
Enabled: true
|
214
|
+
|
215
|
+
Lint/StructNewOverride:
|
216
|
+
Enabled: true
|
217
|
+
|
218
|
+
Lint/DeprecatedOpenSSLConstant:
|
219
|
+
Enabled: true
|
220
|
+
|
221
|
+
Lint/MixedRegexpCaptureTypes:
|
222
|
+
Enabled: true
|
223
|
+
|
224
|
+
Lint/DuplicateElsifCondition:
|
225
|
+
Enabled: true
|
226
|
+
|
227
|
+
Lint/BinaryOperatorWithIdenticalOperands:
|
228
|
+
Enabled: true
|
229
|
+
|
230
|
+
Lint/DuplicateRescueException:
|
231
|
+
Enabled: true
|
232
|
+
|
233
|
+
Lint/EmptyConditionalBody:
|
234
|
+
Enabled: true
|
235
|
+
|
236
|
+
Lint/FloatComparison:
|
237
|
+
Enabled: true
|
238
|
+
|
239
|
+
Lint/MissingSuper:
|
240
|
+
Enabled: true
|
241
|
+
|
242
|
+
Lint/OutOfRangeRegexpRef:
|
243
|
+
Enabled: true
|
244
|
+
|
245
|
+
Lint/SelfAssignment:
|
246
|
+
Enabled: true
|
247
|
+
|
248
|
+
Lint/TopLevelReturnWithArgument:
|
249
|
+
Enabled: true
|
250
|
+
|
251
|
+
Lint/UnreachableLoop:
|
252
|
+
Enabled: true
|
253
|
+
|
254
|
+
# === NAMING ===
|
255
|
+
|
256
|
+
Naming/PredicatePrefix:
|
257
|
+
ForbiddenPrefixes:
|
258
|
+
- is_
|
259
|
+
AllowedMethods:
|
260
|
+
- is_a?
|
261
|
+
|
262
|
+
Naming/MemoizedInstanceVariableName:
|
263
|
+
EnforcedStyleForLeadingUnderscores: required
|
264
|
+
|
265
|
+
Naming/VariableNumber:
|
266
|
+
EnforcedStyle: snake_case
|
267
|
+
|
268
|
+
# === SECURITY ===
|
269
|
+
|
270
|
+
Security/Open:
|
271
|
+
Enabled: true
|
272
|
+
|
273
|
+
Security/YAMLLoad:
|
274
|
+
Enabled: true
|
275
|
+
|
276
|
+
Security/JSONLoad:
|
277
|
+
Enabled: true
|
278
|
+
|
279
|
+
# === PERFORMANCE ===
|
280
|
+
|
281
|
+
Performance/AncestorsInclude:
|
282
|
+
Enabled: true
|
283
|
+
|
284
|
+
Performance/BigDecimalWithNumericArgument:
|
285
|
+
Enabled: true
|
286
|
+
|
287
|
+
Performance/RedundantSortBlock:
|
288
|
+
Enabled: true
|
289
|
+
|
290
|
+
Performance/RedundantStringChars:
|
291
|
+
Enabled: true
|
292
|
+
|
293
|
+
Performance/ReverseFirst:
|
294
|
+
Enabled: true
|
295
|
+
|
296
|
+
Performance/SortReverse:
|
297
|
+
Enabled: true
|
298
|
+
|
299
|
+
Performance/Squeeze:
|
300
|
+
Enabled: true
|
301
|
+
|
302
|
+
Performance/StringInclude:
|
303
|
+
Enabled: true
|
304
|
+
|
305
|
+
Performance/Sum:
|
306
|
+
Enabled: true
|
307
|
+
|
308
|
+
# === MINITEST ===
|
309
|
+
|
310
|
+
Minitest/MultipleAssertions:
|
311
|
+
Max: 10
|
312
|
+
|
313
|
+
Minitest/AssertTruthy:
|
314
|
+
Enabled: true
|
315
|
+
|
316
|
+
Minitest/AssertWithExpectedArgument:
|
317
|
+
Enabled: true
|
318
|
+
|
319
|
+
Minitest/RefuteFalse:
|
320
|
+
Enabled: true
|
321
|
+
|
322
|
+
Minitest/RefuteNil:
|
323
|
+
Enabled: true
|
324
|
+
|
325
|
+
Minitest/TestMethodName:
|
326
|
+
Enabled: true
|
data/Dockerfile.example
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Example Dockerfile for running Prescient gem applications
|
2
|
+
FROM ruby:3.4-alpine
|
3
|
+
|
4
|
+
# Install system dependencies
|
5
|
+
RUN apk add --no-cache \
|
6
|
+
build-base \
|
7
|
+
curl \
|
8
|
+
git \
|
9
|
+
postgresql-dev \
|
10
|
+
tzdata
|
11
|
+
|
12
|
+
# Set working directory
|
13
|
+
WORKDIR /app
|
14
|
+
|
15
|
+
# Create non-root user
|
16
|
+
RUN addgroup -g 1000 -S appuser && \
|
17
|
+
adduser -u 1000 -S appuser -G appuser
|
18
|
+
|
19
|
+
# Copy Gemfile and Gemfile.lock
|
20
|
+
COPY Gemfile* ./
|
21
|
+
COPY prescient.gemspec ./
|
22
|
+
COPY lib/prescient/version.rb ./lib/prescient/
|
23
|
+
|
24
|
+
# Install gems
|
25
|
+
RUN bundle config --global frozen 1 && \
|
26
|
+
bundle install --jobs 4 --retry 3
|
27
|
+
|
28
|
+
# Copy application code
|
29
|
+
COPY . .
|
30
|
+
|
31
|
+
# Change ownership to appuser
|
32
|
+
RUN chown -R appuser:appuser /app
|
33
|
+
|
34
|
+
# Switch to non-root user
|
35
|
+
USER appuser
|
36
|
+
|
37
|
+
# Expose port (if running a web service)
|
38
|
+
EXPOSE 3000
|
39
|
+
|
40
|
+
# Default command
|
41
|
+
CMD ["bundle", "exec", "ruby", "examples/custom_contexts.rb"]
|