Class: LanguageOperator::Dsl::ChatEndpointDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/language_operator/dsl/chat_endpoint_definition.rb

Overview

Chat endpoint definition for agents

DEPRECATED: This class is deprecated. All agents now automatically get identity-aware chat endpoints without configuration. The as_chat_endpoint DSL method is no longer needed.

Allows agents to expose an OpenAI-compatible chat completion endpoint. Other systems can treat the agent as a language model.

Examples:

Define basic chat endpoint

agent "github-expert" do
  as_chat_endpoint do
    system_prompt "You are a GitHub API expert"
    temperature 0.7
    max_tokens 2000
  end
end

Define chat endpoint with identity awareness

agent "support-bot" do
  as_chat_endpoint do
    system_prompt "You are a helpful customer support assistant"

    # Configure identity awareness and context injection
    identity_awareness do
      enabled true
      prompt_template :detailed
      context_injection :standard
    end

    temperature 0.8
  end
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(agent_name) ⇒ ChatEndpointDefinition

Returns a new instance of ChatEndpointDefinition.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/language_operator/dsl/chat_endpoint_definition.rb', line 43

def initialize(agent_name)
  @agent_name = agent_name
  @system_prompt = nil
  @temperature = 0.7
  @max_tokens = 2000
  @model_name = agent_name
  @top_p = 1.0
  @frequency_penalty = 0.0
  @presence_penalty = 0.0
  @stop_sequences = nil
  
  # Identity awareness and context injection settings
  @identity_awareness_enabled = true
  @prompt_template_level = :standard
  @context_injection_level = :standard
end

Instance Attribute Details

#context_injection_levelObject (readonly)

Returns the value of attribute context_injection_level.



39
40
41
# File 'lib/language_operator/dsl/chat_endpoint_definition.rb', line 39

def context_injection_level
  @context_injection_level
end

#frequency_penalty(value = nil) ⇒ Float (readonly)

Set frequency penalty

Parameters:

  • value (Float) (defaults to: nil)

    Frequency penalty (-2.0 to 2.0)

Returns:

  • (Float)

    Current frequency penalty



114
115
116
# File 'lib/language_operator/dsl/chat_endpoint_definition.rb', line 114

def frequency_penalty
  @frequency_penalty
end

#identity_awareness_enabledObject (readonly)

Returns the value of attribute identity_awareness_enabled.



39
40
41
# File 'lib/language_operator/dsl/chat_endpoint_definition.rb', line 39

def identity_awareness_enabled
  @identity_awareness_enabled
end

#max_tokens(value = nil) ⇒ Integer (readonly)

Set maximum tokens

Parameters:

  • value (Integer) (defaults to: nil)

    Max tokens

Returns:

  • (Integer)

    Current max tokens



84
85
86
# File 'lib/language_operator/dsl/chat_endpoint_definition.rb', line 84

def max_tokens
  @max_tokens
end

#model_nameObject (readonly)

Returns the value of attribute model_name.



39
40
41
# File 'lib/language_operator/dsl/chat_endpoint_definition.rb', line 39

def model_name
  @model_name
end

#presence_penalty(value = nil) ⇒ Float (readonly)

Set presence penalty

Parameters:

  • value (Float) (defaults to: nil)

    Presence penalty (-2.0 to 2.0)

Returns:

  • (Float)

    Current presence penalty



124
125
126
# File 'lib/language_operator/dsl/chat_endpoint_definition.rb', line 124

def presence_penalty
  @presence_penalty
end

#prompt_template_levelObject (readonly)

Returns the value of attribute prompt_template_level.



39
40
41
# File 'lib/language_operator/dsl/chat_endpoint_definition.rb', line 39

def prompt_template_level
  @prompt_template_level
end

#stop_sequencesObject (readonly)

Returns the value of attribute stop_sequences.



39
40
41
# File 'lib/language_operator/dsl/chat_endpoint_definition.rb', line 39

def stop_sequences
  @stop_sequences
end

#system_prompt(prompt = nil) ⇒ String (readonly)

Set system prompt for chat mode

Parameters:

  • prompt (String) (defaults to: nil)

    System prompt

Returns:

  • (String)

    Current system prompt



64
65
66
# File 'lib/language_operator/dsl/chat_endpoint_definition.rb', line 64

def system_prompt
  @system_prompt
end

#temperature(value = nil) ⇒ Float (readonly)

Set temperature parameter

Parameters:

  • value (Float) (defaults to: nil)

    Temperature (0.0-2.0)

Returns:

  • (Float)

    Current temperature



74
75
76
# File 'lib/language_operator/dsl/chat_endpoint_definition.rb', line 74

def temperature
  @temperature
end

#top_p(value = nil) ⇒ Float (readonly)

Set top_p parameter

Parameters:

  • value (Float) (defaults to: nil)

    Top-p (0.0-1.0)

Returns:

  • (Float)

    Current top_p



104
105
106
# File 'lib/language_operator/dsl/chat_endpoint_definition.rb', line 104

def top_p
  @top_p
end

Instance Method Details

#context_injection(level = nil) ⇒ Symbol Also known as: context

Set the context injection level for conversations

Controls how much operational context is injected into ongoing conversations.

Available levels:

  • :none - No context injection
  • :minimal - Basic status only
  • :standard - Standard operational context (default)
  • :detailed - Full context with metrics

Parameters:

  • level (Symbol) (defaults to: nil)

    Context injection level

Returns:

  • (Symbol)

    Current context injection level



186
187
188
189
190
191
192
193
194
195
# File 'lib/language_operator/dsl/chat_endpoint_definition.rb', line 186

def context_injection(level = nil)
  return @context_injection_level if level.nil?

  valid_levels = [:none, :minimal, :standard, :detailed]
  unless valid_levels.include?(level)
    raise ArgumentError, "Invalid context level: #{level}. Must be one of: #{valid_levels.join(', ')}"
  end

  @context_injection_level = level
end

#enable_identity_awareness(enabled = nil) ⇒ Boolean Also known as: enabled

Enable or disable identity awareness and context injection

When enabled, the system prompt will be dynamically enhanced with agent identity, operational context, and environment information.

Parameters:

  • enabled (Boolean) (defaults to: nil)

    Whether to enable identity awareness

Returns:

  • (Boolean)

    Current setting



147
148
149
150
151
# File 'lib/language_operator/dsl/chat_endpoint_definition.rb', line 147

def enable_identity_awareness(enabled = nil)
  return @identity_awareness_enabled if enabled.nil?

  @identity_awareness_enabled = enabled
end

#identity_awareness { ... } ⇒ Object

Configure identity awareness with options block

Examples:

identity_awareness do
  enabled true
  prompt_template :detailed
  context_injection :standard
end

Yields:

  • Block for configuring identity awareness options



207
208
209
210
211
212
213
214
215
216
217
# File 'lib/language_operator/dsl/chat_endpoint_definition.rb', line 207

def identity_awareness(&block)
  if block_given?
    instance_eval(&block)
  else
    {
      enabled: @identity_awareness_enabled,
      prompt_template: @prompt_template_level,
      context_injection: @context_injection_level
    }
  end
end

#model(name = nil) ⇒ String

Set model name exposed in API

Parameters:

  • name (String) (defaults to: nil)

    Model name

Returns:

  • (String)

    Current model name



94
95
96
97
98
# File 'lib/language_operator/dsl/chat_endpoint_definition.rb', line 94

def model(name = nil)
  return @model_name if name.nil?

  @model_name = name
end

#prompt_template(level = nil) ⇒ Symbol Also known as: template

Set the prompt template level for context injection

Available levels:

  • :minimal - Basic agent identity only
  • :standard - Identity + basic operational context (default)
  • :detailed - Full context with capabilities
  • :comprehensive - All available context and guidelines

Parameters:

  • level (Symbol) (defaults to: nil)

    Template level

Returns:

  • (Symbol)

    Current template level



163
164
165
166
167
168
169
170
171
172
# File 'lib/language_operator/dsl/chat_endpoint_definition.rb', line 163

def prompt_template(level = nil)
  return @prompt_template_level if level.nil?

  valid_levels = [:minimal, :standard, :detailed, :comprehensive]
  unless valid_levels.include?(level)
    raise ArgumentError, "Invalid template level: #{level}. Must be one of: #{valid_levels.join(', ')}"
  end

  @prompt_template_level = level
end

#stop(sequences = nil) ⇒ Array<String>

Set stop sequences

Parameters:

  • sequences (Array<String>) (defaults to: nil)

    Stop sequences

Returns:

  • (Array<String>)

    Current stop sequences



134
135
136
137
138
# File 'lib/language_operator/dsl/chat_endpoint_definition.rb', line 134

def stop(sequences = nil)
  return @stop_sequences if sequences.nil?

  @stop_sequences = sequences
end