Class: Async::Ollama::Chat

Inherits:
Object
  • Object
show all
Defined in:
lib/async/ollama/chat.rb

Overview

Represents a chat response from the Ollama API, including message content, model, and timing information.

Instance Method Summary collapse

Instance Method Details

#errorObject



25
26
27
# File 'lib/async/ollama/chat.rb', line 25

def error
	self.value[:error]
end

#eval_countInteger | nil

Returns The number of tokens in the response.

Returns:

  • (Integer | nil)

    The number of tokens in the response.



62
63
64
# File 'lib/async/ollama/chat.rb', line 62

def eval_count
	self.value[:eval_count]
end

#eval_durationInteger | nil

Returns The time spent generating the response, in nanoseconds.

Returns:

  • (Integer | nil)

    The time spent generating the response, in nanoseconds.



67
68
69
# File 'lib/async/ollama/chat.rb', line 67

def eval_duration
	self.value[:eval_duration]
end

#load_durationInteger | nil

Returns The time spent loading the model, in nanoseconds.

Returns:

  • (Integer | nil)

    The time spent loading the model, in nanoseconds.



47
48
49
# File 'lib/async/ollama/chat.rb', line 47

def load_duration
	self.value[:load_duration]
end

#messageObject



14
15
16
# File 'lib/async/ollama/chat.rb', line 14

def message
	self.value[:message]
end

#modelObject



37
38
39
# File 'lib/async/ollama/chat.rb', line 37

def model
	self.value[:model]
end

#prompt_eval_countInteger | nil

Returns The number of tokens in the prompt (the token count).

Returns:

  • (Integer | nil)

    The number of tokens in the prompt (the token count).



52
53
54
# File 'lib/async/ollama/chat.rb', line 52

def prompt_eval_count
	self.value[:prompt_eval_count]
end

#prompt_eval_durationInteger | nil

Returns The time spent evaluating the prompt, in nanoseconds.

Returns:

  • (Integer | nil)

    The time spent evaluating the prompt, in nanoseconds.



57
58
59
# File 'lib/async/ollama/chat.rb', line 57

def prompt_eval_duration
	self.value[:prompt_eval_duration]
end

#responseObject



18
19
20
21
22
# File 'lib/async/ollama/chat.rb', line 18

def response
	if message = self.message
		message[:content]
	end
end

#token_countInteger

Returns The sum of prompt and response token counts.

Returns:

  • (Integer)

    The sum of prompt and response token counts.



72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/async/ollama/chat.rb', line 72

def token_count
	count = 0
	
	if prompt_eval_count = self.prompt_eval_count
		count += prompt_eval_count
	end
	
	if eval_count = self.eval_count
		count += eval_count
	end
	
	return count
end

#tool_callsObject



30
31
32
33
34
# File 'lib/async/ollama/chat.rb', line 30

def tool_calls
	if message = self.message
		message[:tool_calls]
	end
end

#total_durationInteger | nil

Returns The time spent generating the response, in nanoseconds.

Returns:

  • (Integer | nil)

    The time spent generating the response, in nanoseconds.



42
43
44
# File 'lib/async/ollama/chat.rb', line 42

def total_duration
	self.value[:total_duration]
end