Class: Omen::Instructions
- Inherits:
-
Object
- Object
- Omen::Instructions
- Defined in:
- app/models/omen/instructions.rb
Overview
Everything Claude is told before a question: the prose, the schema, and the shape of a reply.
Constant Summary collapse
- PROSE =
The prose, kept beside this class so it reads as prose rather than as a string.
File. 'instructions.md', __dir__
- TIME_ZONE =
The database function a stored timestamp is read through, created by the gem's rake task. Every one of these is prefixed, since
todayespecially is a name a host may want itself. 'omen_time_zone'- TODAY =
The database function that answers what day it is where the company works.
'omen_today'- MILES =
The database function a distance in miles is measured with, created by the same task.
'omen_miles_between'- ANSWER =
The one shape a reply may take: both keys required, and no others admitted.
{ type: 'object', additionalProperties: false, required: %w[ sql note combine ], properties: { sql: { type: 'string', description: 'The one PostgreSQL SELECT that answers the question, or ' \ 'empty to ask something first.', }, note: { type: 'string', description: 'A sentence or two: what the query returns and any ' \ 'assumption made. If sql is empty, the question you ' \ 'need answered first.', }, combine: Omen::Combination::SCHEMA, }, }
Class Method Summary collapse
-
.block ⇒ Array<Hash>
Cached for an hour: the schema is thousands of tokens, and refining sends it again.
-
.output_config ⇒ Hash
What a reply is constrained to, so that it always parses.
Instance Method Summary collapse
-
#text ⇒ String
Today's date is said out loud because "last month" is Claude's to resolve, and it has no clock.
Class Method Details
.block ⇒ Array<Hash>
Cached for an hour: the schema is thousands of tokens, and refining sends it again.
36 37 38 |
# File 'app/models/omen/instructions.rb', line 36 def self.block [ { type: 'text', text: new.text, cache_control: { type: 'ephemeral', ttl: '1h' } } ] end |
.output_config ⇒ Hash
Returns what a reply is constrained to, so that it always parses.
32 |
# File 'app/models/omen/instructions.rb', line 32 def self.output_config = { format_: { type: :json_schema, schema: ANSWER } } |
Instance Method Details
#text ⇒ String
Today's date is said out loud because "last month" is Claude's to resolve, and it has no clock.
42 43 44 45 46 47 |
# File 'app/models/omen/instructions.rb', line 42 def text format File.read(PROSE), today: Date.current.to_fs(:long), zone_fn: TIME_ZONE, today_fn: TODAY, miles_fn: MILES, schema: schema, types: types, readable: readable, refused: refused, notes: Omen.config.notes end |