Class: Insika::Evals::Persona
- Inherits:
-
Struct
- Object
- Struct
- Insika::Evals::Persona
- Defined in:
- lib/insika/evals/persona.rb
Overview
A SIMULATED CUSTOMER — the data that turns a scripted case into a generated conversation. Pure data: goal, style, the opening message, the ONLY facts the persona may assert, and a hard turn cap. The persona is played by a model (the cheap utility_model) with this as its whole instruction; the anti-invention rule below is the soul of the feature — a simulator that invents an order number produces a conversation the agent could never have had, and a case that tests nothing.
Instance Attribute Summary collapse
-
#goal ⇒ Object
Returns the value of attribute goal.
-
#knows ⇒ Object
Returns the value of attribute knows.
-
#max_turns ⇒ Object
Returns the value of attribute max_turns.
-
#opens_with ⇒ Object
Returns the value of attribute opens_with.
-
#style ⇒ Object
Returns the value of attribute style.
Instance Method Summary collapse
-
#prompt(transcript) ⇒ Object
The persona as a whole instruction.
- #to_h ⇒ Object
Instance Attribute Details
#goal ⇒ Object
Returns the value of attribute goal
12 13 14 |
# File 'lib/insika/evals/persona.rb', line 12 def goal @goal end |
#knows ⇒ Object
Returns the value of attribute knows
12 13 14 |
# File 'lib/insika/evals/persona.rb', line 12 def knows @knows end |
#max_turns ⇒ Object
Returns the value of attribute max_turns
12 13 14 |
# File 'lib/insika/evals/persona.rb', line 12 def max_turns @max_turns end |
#opens_with ⇒ Object
Returns the value of attribute opens_with
12 13 14 |
# File 'lib/insika/evals/persona.rb', line 12 def opens_with @opens_with end |
#style ⇒ Object
Returns the value of attribute style
12 13 14 |
# File 'lib/insika/evals/persona.rb', line 12 def style @style end |
Instance Method Details
#prompt(transcript) ⇒ Object
The persona as a whole instruction. The knows facts are the ONLY
assertions the persona may make; anything else is answered with
ignorance — "não sei", "não tenho isso aqui" — exactly like a real
customer who does not have the fact. transcript is the conversation
so far, in order, as [{ role: "user"|"assistant", text: }].
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/insika/evals/persona.rb', line 23 def prompt(transcript) facts = knows.map { |k, v| "- #{k}: #{v}" }.join("\n") <<~PROMPT You are simulating a customer in a chat with a store's virtual assistant. Stay in character. You are not helping the assistant; you are the person it serves. GOAL: #{goal} STYLE: #{style || "short, natural messages; answers what is asked"} FACTS YOU KNOW — the ONLY facts you may assert: #{facts} RULES: 1. You may ONLY assert the facts above. Asked about anything else, you do not know it — answer with ignorance, like a real customer without that fact (you have no order number, no name, no date, no price beyond the facts above). Never invent an order number, a name, a date, a price or any other detail that is not in FACTS YOU KNOW. 2. Reply with ONLY the customer's next message. 3. When your goal has been met, end the message with the marker <<goal_met>>. When you give up (the assistant cannot get you there), end the message with the marker <<gave_up>>. Otherwise end with no marker. CONVERSATION SO FAR: #{transcript.map { |m| "#{m[:role]}: #{m[:text]}" }.join("\n")} Your next message: PROMPT end |
#to_h ⇒ Object
13 14 15 16 |
# File 'lib/insika/evals/persona.rb', line 13 def to_h { "goal" => goal, "style" => style, "opens_with" => opens_with, "knows" => knows, "max_turns" => max_turns }.compact end |