ollama_chat 0.0.64 → 0.0.65

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fcb955cd7607555be0e5cf86a3cc9f1ee346a0e7e316dc2cb747ec5891ab2aa3
4
- data.tar.gz: c012ef755865d3070e171438bc297ac8867ad9c229c8bb2cb64d8443edee5f14
3
+ metadata.gz: 93d007af4b92cbca56b9738f9b2121d460bcff227beaee8f97b8a3fafd362797
4
+ data.tar.gz: e29f2db240c9d232e98e1381c3ef56b34db959d93fe2a15035e0ca55c85bc372
5
5
  SHA512:
6
- metadata.gz: 0d6c66f01bf73150d6c5933193d23069df1993dfa70238262ccdedf72aa37841368185d00139cb2f10f7949e1a6eeeb2ff1453e68002dd40cb0ff3395c5cc497
7
- data.tar.gz: 8651e4210a799e4bf95ddffb80dfced2c4ae90e49426c9ab34b9743393b11476dc113b057be1d03266129605dfdb51af550bacc67d955638b3d35d0de89597e6
6
+ metadata.gz: d914de741cbcb653a8a937b0ab298249be6ea3a933e609de96ec5c4ba87d9faa55cc65577f8ebec31b4b6f43927e8b33d245ad3bab82a1a5e48d155522370983
7
+ data.tar.gz: 052d95396af6f76ec7c8978d4cc2e70117aa7cf55ad922dc0454a3fa2b54ddf5d2ee621060fc9ab53837949ca89c4edbf8c6b549e7c56806a974ddd909308871
data/CHANGES.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-02-10 v0.0.65
4
+
5
+ - Updated `location_handling.rb` to return only `location_name`,
6
+ `location_decimal_degrees`, and `units`
7
+ - Removed `localtime` from `location_data` and prompt template in
8
+ `lib/ollama_chat/location_handling.rb`
9
+ - Updated `default_config.yml` location prompt to exclude `on %{localtime}`
10
+ - Simplified location switch messages in `switches.rb`
11
+ - Added new tool `GetTime` in `lib/ollama_chat/tools/get_time.rb` returning
12
+ ISO8601 time
13
+ - Updated `tools.rb` to require `get_time`
14
+ - Updated `tools/get_location.rb` comments and description
15
+ - Added `get_time_spec.rb` to `test_files` listing
16
+ - Added `get_time.rb` to `extra_rdoc_files` and `files` listings
17
+ - Removed duplicate `get_time.rb` entries from `extra_rdoc_files` and `files`
18
+ listings
19
+ - Updated specs: `message_list_spec.rb`, `tools/get_location_spec.rb`, added
20
+ `tools/get_time_spec.rb`
21
+ - Adjusted regexes in specs to match new prompt format
22
+ - Removed unused `time` field from `location_data` in tests
23
+
3
24
  ## 2026-02-09 v0.0.64
4
25
 
5
26
  - Added new `OllamaChat::Tools::GetJiraIssue` tool for fetching JIRA issue
@@ -6,10 +6,6 @@
6
6
  # voice synthesis for spoken responses. It acts as a handler for streaming
7
7
  # responses and ensures proper formatting and display of both regular content
8
8
  # and thinking annotations.
9
- #
10
- # @example Processing a chat response
11
- # follow_chat = OllamaChat::FollowChat.new(chat: chat_instance, messages: message_list)
12
- # follow_chat.tool_call(response)
13
9
  class OllamaChat::FollowChat
14
10
  include Ollama
15
11
  include Ollama::Handlers::Concern
@@ -6,7 +6,7 @@
6
6
  # configuration to provide contextual location information to language models.
7
7
  #
8
8
  # @example Generating location information
9
- # chat.location_data # => { location_name: "New York", location_decimal_degrees: "40.7128, -74.0060", localtime: "2023-10-15T10:30:00Z", units: "metric" }
9
+ # chat.location_data # => { location_name: "New York", location_decimal_degrees: "40.7128, -74.0060", units: "metric" }
10
10
  # chat.location_description # => "Current location: New York (40.7128, -74.0060) at 2023-10-15T10:30:00Z in metric units"
11
11
  #
12
12
  # @see OllamaChat::Chat
@@ -15,7 +15,7 @@ module OllamaChat::LocationHandling
15
15
  # data.
16
16
  #
17
17
  # This method creates a formatted string containing location information
18
- # including name, coordinates, local time, and units, using the configured
18
+ # including name, coordinates, local and units, using the configured
19
19
  # location prompt template.
20
20
  #
21
21
  # @return [String] a formatted location description string
@@ -27,18 +27,16 @@ module OllamaChat::LocationHandling
27
27
  # Generates a hash containing current location data.
28
28
  #
29
29
  # This method collects and returns structured location information including
30
- # the location name, decimal degrees coordinates, local time, and units.
30
+ # the location name, decimal degrees coordinates, and units.
31
31
  #
32
32
  # @return [Hash] a hash containing location data with keys:
33
33
  # - location_name: The name of the location
34
34
  # - location_decimal_degrees: Comma-separated decimal degrees coordinates
35
- # - localtime: Current local time in ISO 8601 format
36
35
  # - units: The unit system (metric, imperial, etc.)
37
36
  def location_data
38
37
  {
39
38
  location_name: config.location.name,
40
39
  location_decimal_degrees: config.location.decimal_degrees * ', ',
41
- localtime: Time.now.iso8601,
42
40
  units: config.location.units,
43
41
  }
44
42
  end
@@ -30,7 +30,7 @@ prompts:
30
30
  Answer the the query %{query} using these summarized sources:
31
31
 
32
32
  %{results}
33
- location: You are at %{location_name}, %{location_decimal_degrees}, on %{localtime}, preferring %{units}
33
+ location: You are at %{location_name}, %{location_decimal_degrees}, preferring %{units}
34
34
  system_prompts:
35
35
  default: <%= OllamaChat::EnvConfig::OLLAMA::CHAT::SYSTEM || 'null' %>
36
36
  assistant: You are a helpful assistant.
@@ -94,6 +94,8 @@ tools:
94
94
  get_endoflife:
95
95
  url: "https://endoflife.date/api/v1/products/%{product}"
96
96
  default: false
97
+ get_time:
98
+ default: true
97
99
  get_location:
98
100
  default: true
99
101
  file_context:
@@ -240,8 +240,8 @@ module OllamaChat::Switches
240
240
  @location = Switch.new(
241
241
  value: config.location.enabled,
242
242
  msg: {
243
- true => "Location and localtime enabled.",
244
- false => "Location and localtime disabled.",
243
+ true => "Location enabled.",
244
+ false => "Location disabled.",
245
245
  }
246
246
  )
247
247
  end
@@ -1,11 +1,11 @@
1
- # A tool for retrieving the current location, time, and system of units.
1
+ # A tool for retrieving the current location, and system of units.
2
2
  #
3
3
  # This tool allows the chat client to get the current location information,
4
- # including time and system of units for the user. It integrates with the
5
- # Ollama tool calling system to provide contextual location data to the language model.
4
+ # and system of units for the user. It integrates with the Ollama tool calling
5
+ # system to provide contextual location data to the language model.
6
6
  #
7
- # The tool returns structured JSON data containing location coordinates, time,
8
- # and unit system information.
7
+ # The tool returns structured JSON data containing location coordinates, and
8
+ # unit system information.
9
9
  class OllamaChat::Tools::GetLocation
10
10
  include OllamaChat::Tools::Concern
11
11
 
@@ -28,7 +28,7 @@ class OllamaChat::Tools::GetLocation
28
28
  type: 'function',
29
29
  function: Tool::Function.new(
30
30
  name:,
31
- description: 'Get the current location, time and system of units of the user as JSON',
31
+ description: 'Get the current location and system of units of the user as JSON',
32
32
  parameters: Tool::Function::Parameters.new(
33
33
  type: 'object',
34
34
  properties: {},
@@ -0,0 +1,49 @@
1
+ require 'time'
2
+
3
+ # get_time.rb – a tool that returns the current time as an ISO8601 string.
4
+ #
5
+ # This file mirrors the structure of get_location.rb and can be dropped into
6
+ # the `lib/ollama_chat/tools` directory. The tool is registered with the
7
+ # Ollama tool‑calling system and can be invoked by name `get_time`.
8
+ #
9
+ # Usage in a chat session:
10
+ # ollama_chat.run('get_time')
11
+ # # => "{\"time\":\"2026-02-09T14:32:00+01:00\"}"
12
+ #
13
+ # The implementation is intentionally lightweight – it simply calls
14
+ # `Time.now.iso8601` and serialises the result as JSON.
15
+ module OllamaChat
16
+ module Tools
17
+ class GetTime
18
+ include OllamaChat::Tools::Concern
19
+
20
+ # Register the tool name for the Ollama tool‑calling system.
21
+ def self.register_name = 'get_time'
22
+
23
+ # Build the function signature for the tool. No parameters are
24
+ # required – the tool simply returns the current time.
25
+ def tool
26
+ Tool.new(
27
+ type: 'function',
28
+ function: Tool::Function.new(
29
+ name:,
30
+ description: 'Get the current time as an ISO8601 string',
31
+ parameters: Tool::Function::Parameters.new(
32
+ type: 'object',
33
+ properties: {},
34
+ required: []
35
+ )
36
+ )
37
+ )
38
+ end
39
+
40
+ # Execute the tool. We return a JSON string containing the time
41
+ # in ISO8601 format. The caller can parse it as needed.
42
+ def execute(_tool_call, **_opts)
43
+ { time: Time.now.iso8601 }.to_json
44
+ end
45
+
46
+ self
47
+ end.register
48
+ end
49
+ end
@@ -48,9 +48,10 @@ require 'ollama_chat/tools/gem_path_lookup'
48
48
  require 'ollama_chat/tools/get_current_weather'
49
49
  require 'ollama_chat/tools/get_cve'
50
50
  require 'ollama_chat/tools/get_endoflife'
51
+ require 'ollama_chat/tools/get_jira_issue'
51
52
  require 'ollama_chat/tools/get_location'
53
+ require 'ollama_chat/tools/get_time'
52
54
  require 'ollama_chat/tools/import_url'
53
- require 'ollama_chat/tools/get_jira_issue'
54
55
  require 'ollama_chat/tools/read_file'
55
56
  require 'ollama_chat/tools/run_tests'
56
57
  require 'ollama_chat/tools/search_web'
@@ -1,6 +1,6 @@
1
1
  module OllamaChat
2
2
  # OllamaChat version
3
- VERSION = '0.0.64'
3
+ VERSION = '0.0.65'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
data/ollama_chat.gemspec CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: ollama_chat 0.0.64 ruby lib
2
+ # stub: ollama_chat 0.0.65 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "ollama_chat".freeze
6
- s.version = "0.0.64".freeze
6
+ s.version = "0.0.65".freeze
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
@@ -12,15 +12,15 @@ Gem::Specification.new do |s|
12
12
  s.description = "The app provides a command-line interface (CLI) to an Ollama AI model,\nallowing users to engage in text-based conversations and generate\nhuman-like responses. Users can import data from local files or web pages,\nwhich are then processed through three different modes: fully importing the\ncontent into the conversation context, summarizing the information for\nconcise reference, or storing it in an embedding vector database for later\nretrieval based on the conversation.\n".freeze
13
13
  s.email = "flori@ping.de".freeze
14
14
  s.executables = ["ollama_chat".freeze, "ollama_chat_send".freeze]
15
- s.extra_rdoc_files = ["README.md".freeze, "lib/ollama_chat.rb".freeze, "lib/ollama_chat/chat.rb".freeze, "lib/ollama_chat/clipboard.rb".freeze, "lib/ollama_chat/conversation.rb".freeze, "lib/ollama_chat/dialog.rb".freeze, "lib/ollama_chat/document_cache.rb".freeze, "lib/ollama_chat/env_config.rb".freeze, "lib/ollama_chat/follow_chat.rb".freeze, "lib/ollama_chat/history.rb".freeze, "lib/ollama_chat/information.rb".freeze, "lib/ollama_chat/input_content.rb".freeze, "lib/ollama_chat/kramdown_ansi.rb".freeze, "lib/ollama_chat/location_handling.rb".freeze, "lib/ollama_chat/message_editing.rb".freeze, "lib/ollama_chat/message_format.rb".freeze, "lib/ollama_chat/message_list.rb".freeze, "lib/ollama_chat/message_output.rb".freeze, "lib/ollama_chat/model_handling.rb".freeze, "lib/ollama_chat/ollama_chat_config.rb".freeze, "lib/ollama_chat/parsing.rb".freeze, "lib/ollama_chat/redis_cache.rb".freeze, "lib/ollama_chat/server_socket.rb".freeze, "lib/ollama_chat/source_fetching.rb".freeze, "lib/ollama_chat/state_selectors.rb".freeze, "lib/ollama_chat/switches.rb".freeze, "lib/ollama_chat/think_control.rb".freeze, "lib/ollama_chat/tool_calling.rb".freeze, "lib/ollama_chat/tools.rb".freeze, "lib/ollama_chat/tools/browse.rb".freeze, "lib/ollama_chat/tools/concern.rb".freeze, "lib/ollama_chat/tools/directory_structure.rb".freeze, "lib/ollama_chat/tools/endoflife.rb".freeze, "lib/ollama_chat/tools/execute_grep.rb".freeze, "lib/ollama_chat/tools/file_context.rb".freeze, "lib/ollama_chat/tools/gem_path_lookup.rb".freeze, "lib/ollama_chat/tools/get_current_weather.rb".freeze, "lib/ollama_chat/tools/get_cve.rb".freeze, "lib/ollama_chat/tools/get_endoflife.rb".freeze, "lib/ollama_chat/tools/get_jira_issue.rb".freeze, "lib/ollama_chat/tools/get_location.rb".freeze, "lib/ollama_chat/tools/import_url.rb".freeze, "lib/ollama_chat/tools/read_file.rb".freeze, "lib/ollama_chat/tools/run_tests.rb".freeze, "lib/ollama_chat/tools/search_web.rb".freeze, "lib/ollama_chat/tools/vim_open_file.rb".freeze, "lib/ollama_chat/tools/weather/dwd_sensor.rb".freeze, "lib/ollama_chat/tools/write_file.rb".freeze, "lib/ollama_chat/utils.rb".freeze, "lib/ollama_chat/utils/analyze_directory.rb".freeze, "lib/ollama_chat/utils/cache_fetcher.rb".freeze, "lib/ollama_chat/utils/chooser.rb".freeze, "lib/ollama_chat/utils/fetcher.rb".freeze, "lib/ollama_chat/utils/file_argument.rb".freeze, "lib/ollama_chat/utils/path_validator.rb".freeze, "lib/ollama_chat/version.rb".freeze, "lib/ollama_chat/vim.rb".freeze, "lib/ollama_chat/web_searching.rb".freeze]
16
- s.files = [".utilsrc".freeze, "CHANGES.md".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "bin/ollama_chat".freeze, "bin/ollama_chat_send".freeze, "config/searxng/settings.yml".freeze, "docker-compose.yml".freeze, "lib/ollama_chat.rb".freeze, "lib/ollama_chat/chat.rb".freeze, "lib/ollama_chat/clipboard.rb".freeze, "lib/ollama_chat/conversation.rb".freeze, "lib/ollama_chat/dialog.rb".freeze, "lib/ollama_chat/document_cache.rb".freeze, "lib/ollama_chat/env_config.rb".freeze, "lib/ollama_chat/follow_chat.rb".freeze, "lib/ollama_chat/history.rb".freeze, "lib/ollama_chat/information.rb".freeze, "lib/ollama_chat/input_content.rb".freeze, "lib/ollama_chat/kramdown_ansi.rb".freeze, "lib/ollama_chat/location_handling.rb".freeze, "lib/ollama_chat/message_editing.rb".freeze, "lib/ollama_chat/message_format.rb".freeze, "lib/ollama_chat/message_list.rb".freeze, "lib/ollama_chat/message_output.rb".freeze, "lib/ollama_chat/model_handling.rb".freeze, "lib/ollama_chat/ollama_chat_config.rb".freeze, "lib/ollama_chat/ollama_chat_config/default_config.yml".freeze, "lib/ollama_chat/parsing.rb".freeze, "lib/ollama_chat/redis_cache.rb".freeze, "lib/ollama_chat/server_socket.rb".freeze, "lib/ollama_chat/source_fetching.rb".freeze, "lib/ollama_chat/state_selectors.rb".freeze, "lib/ollama_chat/switches.rb".freeze, "lib/ollama_chat/think_control.rb".freeze, "lib/ollama_chat/tool_calling.rb".freeze, "lib/ollama_chat/tools.rb".freeze, "lib/ollama_chat/tools/browse.rb".freeze, "lib/ollama_chat/tools/concern.rb".freeze, "lib/ollama_chat/tools/directory_structure.rb".freeze, "lib/ollama_chat/tools/endoflife.rb".freeze, "lib/ollama_chat/tools/execute_grep.rb".freeze, "lib/ollama_chat/tools/file_context.rb".freeze, "lib/ollama_chat/tools/gem_path_lookup.rb".freeze, "lib/ollama_chat/tools/get_current_weather.rb".freeze, "lib/ollama_chat/tools/get_cve.rb".freeze, "lib/ollama_chat/tools/get_endoflife.rb".freeze, "lib/ollama_chat/tools/get_jira_issue.rb".freeze, "lib/ollama_chat/tools/get_location.rb".freeze, "lib/ollama_chat/tools/import_url.rb".freeze, "lib/ollama_chat/tools/read_file.rb".freeze, "lib/ollama_chat/tools/run_tests.rb".freeze, "lib/ollama_chat/tools/search_web.rb".freeze, "lib/ollama_chat/tools/vim_open_file.rb".freeze, "lib/ollama_chat/tools/weather/dwd_sensor.rb".freeze, "lib/ollama_chat/tools/write_file.rb".freeze, "lib/ollama_chat/utils.rb".freeze, "lib/ollama_chat/utils/analyze_directory.rb".freeze, "lib/ollama_chat/utils/cache_fetcher.rb".freeze, "lib/ollama_chat/utils/chooser.rb".freeze, "lib/ollama_chat/utils/fetcher.rb".freeze, "lib/ollama_chat/utils/file_argument.rb".freeze, "lib/ollama_chat/utils/path_validator.rb".freeze, "lib/ollama_chat/version.rb".freeze, "lib/ollama_chat/vim.rb".freeze, "lib/ollama_chat/web_searching.rb".freeze, "ollama_chat.gemspec".freeze, "redis/redis.conf".freeze, "spec/assets/api_show.json".freeze, "spec/assets/api_tags.json".freeze, "spec/assets/api_version.json".freeze, "spec/assets/conversation.json".freeze, "spec/assets/deep/deeper/empty.txt".freeze, "spec/assets/deep/deeper/not-empty.txt".freeze, "spec/assets/deep/empty.txt".freeze, "spec/assets/duckduckgo.html".freeze, "spec/assets/example.atom".freeze, "spec/assets/example.csv".freeze, "spec/assets/example.html".freeze, "spec/assets/example.pdf".freeze, "spec/assets/example.ps".freeze, "spec/assets/example.rb".freeze, "spec/assets/example.rss".freeze, "spec/assets/example.xml".freeze, "spec/assets/example_with_quote.html".freeze, "spec/assets/kitten.jpg".freeze, "spec/assets/prompt.txt".freeze, "spec/assets/searxng.json".freeze, "spec/ollama_chat/chat_spec.rb".freeze, "spec/ollama_chat/clipboard_spec.rb".freeze, "spec/ollama_chat/follow_chat_spec.rb".freeze, "spec/ollama_chat/information_spec.rb".freeze, "spec/ollama_chat/input_content_spec.rb".freeze, "spec/ollama_chat/kramdown_ansi_spec.rb".freeze, "spec/ollama_chat/message_editing_spec.rb".freeze, "spec/ollama_chat/message_list_spec.rb".freeze, "spec/ollama_chat/message_output_spec.rb".freeze, "spec/ollama_chat/model_handling_spec.rb".freeze, "spec/ollama_chat/parsing_spec.rb".freeze, "spec/ollama_chat/redis_cache_spec.rb".freeze, "spec/ollama_chat/server_socket_spec.rb".freeze, "spec/ollama_chat/source_fetching_spec.rb".freeze, "spec/ollama_chat/state_selectors_spec.rb".freeze, "spec/ollama_chat/switches_spec.rb".freeze, "spec/ollama_chat/think_control_spec.rb".freeze, "spec/ollama_chat/tools/browse_spec.rb".freeze, "spec/ollama_chat/tools/directory_structure_spec.rb".freeze, "spec/ollama_chat/tools/execute_grep_spec.rb".freeze, "spec/ollama_chat/tools/file_context_spec.rb".freeze, "spec/ollama_chat/tools/gem_path_lookup_spec.rb".freeze, "spec/ollama_chat/tools/get_current_weather_spec.rb".freeze, "spec/ollama_chat/tools/get_cve_spec.rb".freeze, "spec/ollama_chat/tools/get_endoflife_spec.rb".freeze, "spec/ollama_chat/tools/get_jira_issue_spec.rb".freeze, "spec/ollama_chat/tools/get_location_spec.rb".freeze, "spec/ollama_chat/tools/import_url_spec.rb".freeze, "spec/ollama_chat/tools/read_file_spec.rb".freeze, "spec/ollama_chat/tools/run_tests_spec.rb".freeze, "spec/ollama_chat/tools/search_web_spec.rb".freeze, "spec/ollama_chat/tools/vim_open_file_spec.rb".freeze, "spec/ollama_chat/tools/write_file_spec.rb".freeze, "spec/ollama_chat/utils/analyze_directory_spec.rb".freeze, "spec/ollama_chat/utils/cache_fetcher_spec.rb".freeze, "spec/ollama_chat/utils/fetcher_spec.rb".freeze, "spec/ollama_chat/utils/file_argument_spec.rb".freeze, "spec/ollama_chat/vim_spec.rb".freeze, "spec/ollama_chat/web_searching_spec.rb".freeze, "spec/spec_helper.rb".freeze, "tmp/.keep".freeze]
15
+ s.extra_rdoc_files = ["README.md".freeze, "lib/ollama_chat.rb".freeze, "lib/ollama_chat/chat.rb".freeze, "lib/ollama_chat/clipboard.rb".freeze, "lib/ollama_chat/conversation.rb".freeze, "lib/ollama_chat/dialog.rb".freeze, "lib/ollama_chat/document_cache.rb".freeze, "lib/ollama_chat/env_config.rb".freeze, "lib/ollama_chat/follow_chat.rb".freeze, "lib/ollama_chat/history.rb".freeze, "lib/ollama_chat/information.rb".freeze, "lib/ollama_chat/input_content.rb".freeze, "lib/ollama_chat/kramdown_ansi.rb".freeze, "lib/ollama_chat/location_handling.rb".freeze, "lib/ollama_chat/message_editing.rb".freeze, "lib/ollama_chat/message_format.rb".freeze, "lib/ollama_chat/message_list.rb".freeze, "lib/ollama_chat/message_output.rb".freeze, "lib/ollama_chat/model_handling.rb".freeze, "lib/ollama_chat/ollama_chat_config.rb".freeze, "lib/ollama_chat/parsing.rb".freeze, "lib/ollama_chat/redis_cache.rb".freeze, "lib/ollama_chat/server_socket.rb".freeze, "lib/ollama_chat/source_fetching.rb".freeze, "lib/ollama_chat/state_selectors.rb".freeze, "lib/ollama_chat/switches.rb".freeze, "lib/ollama_chat/think_control.rb".freeze, "lib/ollama_chat/tool_calling.rb".freeze, "lib/ollama_chat/tools.rb".freeze, "lib/ollama_chat/tools/browse.rb".freeze, "lib/ollama_chat/tools/concern.rb".freeze, "lib/ollama_chat/tools/directory_structure.rb".freeze, "lib/ollama_chat/tools/endoflife.rb".freeze, "lib/ollama_chat/tools/execute_grep.rb".freeze, "lib/ollama_chat/tools/file_context.rb".freeze, "lib/ollama_chat/tools/gem_path_lookup.rb".freeze, "lib/ollama_chat/tools/get_current_weather.rb".freeze, "lib/ollama_chat/tools/get_cve.rb".freeze, "lib/ollama_chat/tools/get_endoflife.rb".freeze, "lib/ollama_chat/tools/get_jira_issue.rb".freeze, "lib/ollama_chat/tools/get_location.rb".freeze, "lib/ollama_chat/tools/get_time.rb".freeze, "lib/ollama_chat/tools/import_url.rb".freeze, "lib/ollama_chat/tools/read_file.rb".freeze, "lib/ollama_chat/tools/run_tests.rb".freeze, "lib/ollama_chat/tools/search_web.rb".freeze, "lib/ollama_chat/tools/vim_open_file.rb".freeze, "lib/ollama_chat/tools/weather/dwd_sensor.rb".freeze, "lib/ollama_chat/tools/write_file.rb".freeze, "lib/ollama_chat/utils.rb".freeze, "lib/ollama_chat/utils/analyze_directory.rb".freeze, "lib/ollama_chat/utils/cache_fetcher.rb".freeze, "lib/ollama_chat/utils/chooser.rb".freeze, "lib/ollama_chat/utils/fetcher.rb".freeze, "lib/ollama_chat/utils/file_argument.rb".freeze, "lib/ollama_chat/utils/path_validator.rb".freeze, "lib/ollama_chat/version.rb".freeze, "lib/ollama_chat/vim.rb".freeze, "lib/ollama_chat/web_searching.rb".freeze]
16
+ s.files = [".utilsrc".freeze, "CHANGES.md".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "bin/ollama_chat".freeze, "bin/ollama_chat_send".freeze, "config/searxng/settings.yml".freeze, "docker-compose.yml".freeze, "lib/ollama_chat.rb".freeze, "lib/ollama_chat/chat.rb".freeze, "lib/ollama_chat/clipboard.rb".freeze, "lib/ollama_chat/conversation.rb".freeze, "lib/ollama_chat/dialog.rb".freeze, "lib/ollama_chat/document_cache.rb".freeze, "lib/ollama_chat/env_config.rb".freeze, "lib/ollama_chat/follow_chat.rb".freeze, "lib/ollama_chat/history.rb".freeze, "lib/ollama_chat/information.rb".freeze, "lib/ollama_chat/input_content.rb".freeze, "lib/ollama_chat/kramdown_ansi.rb".freeze, "lib/ollama_chat/location_handling.rb".freeze, "lib/ollama_chat/message_editing.rb".freeze, "lib/ollama_chat/message_format.rb".freeze, "lib/ollama_chat/message_list.rb".freeze, "lib/ollama_chat/message_output.rb".freeze, "lib/ollama_chat/model_handling.rb".freeze, "lib/ollama_chat/ollama_chat_config.rb".freeze, "lib/ollama_chat/ollama_chat_config/default_config.yml".freeze, "lib/ollama_chat/parsing.rb".freeze, "lib/ollama_chat/redis_cache.rb".freeze, "lib/ollama_chat/server_socket.rb".freeze, "lib/ollama_chat/source_fetching.rb".freeze, "lib/ollama_chat/state_selectors.rb".freeze, "lib/ollama_chat/switches.rb".freeze, "lib/ollama_chat/think_control.rb".freeze, "lib/ollama_chat/tool_calling.rb".freeze, "lib/ollama_chat/tools.rb".freeze, "lib/ollama_chat/tools/browse.rb".freeze, "lib/ollama_chat/tools/concern.rb".freeze, "lib/ollama_chat/tools/directory_structure.rb".freeze, "lib/ollama_chat/tools/endoflife.rb".freeze, "lib/ollama_chat/tools/execute_grep.rb".freeze, "lib/ollama_chat/tools/file_context.rb".freeze, "lib/ollama_chat/tools/gem_path_lookup.rb".freeze, "lib/ollama_chat/tools/get_current_weather.rb".freeze, "lib/ollama_chat/tools/get_cve.rb".freeze, "lib/ollama_chat/tools/get_endoflife.rb".freeze, "lib/ollama_chat/tools/get_jira_issue.rb".freeze, "lib/ollama_chat/tools/get_location.rb".freeze, "lib/ollama_chat/tools/get_time.rb".freeze, "lib/ollama_chat/tools/import_url.rb".freeze, "lib/ollama_chat/tools/read_file.rb".freeze, "lib/ollama_chat/tools/run_tests.rb".freeze, "lib/ollama_chat/tools/search_web.rb".freeze, "lib/ollama_chat/tools/vim_open_file.rb".freeze, "lib/ollama_chat/tools/weather/dwd_sensor.rb".freeze, "lib/ollama_chat/tools/write_file.rb".freeze, "lib/ollama_chat/utils.rb".freeze, "lib/ollama_chat/utils/analyze_directory.rb".freeze, "lib/ollama_chat/utils/cache_fetcher.rb".freeze, "lib/ollama_chat/utils/chooser.rb".freeze, "lib/ollama_chat/utils/fetcher.rb".freeze, "lib/ollama_chat/utils/file_argument.rb".freeze, "lib/ollama_chat/utils/path_validator.rb".freeze, "lib/ollama_chat/version.rb".freeze, "lib/ollama_chat/vim.rb".freeze, "lib/ollama_chat/web_searching.rb".freeze, "ollama_chat.gemspec".freeze, "redis/redis.conf".freeze, "spec/assets/api_show.json".freeze, "spec/assets/api_tags.json".freeze, "spec/assets/api_version.json".freeze, "spec/assets/conversation.json".freeze, "spec/assets/deep/deeper/empty.txt".freeze, "spec/assets/deep/deeper/not-empty.txt".freeze, "spec/assets/deep/empty.txt".freeze, "spec/assets/duckduckgo.html".freeze, "spec/assets/example.atom".freeze, "spec/assets/example.csv".freeze, "spec/assets/example.html".freeze, "spec/assets/example.pdf".freeze, "spec/assets/example.ps".freeze, "spec/assets/example.rb".freeze, "spec/assets/example.rss".freeze, "spec/assets/example.xml".freeze, "spec/assets/example_with_quote.html".freeze, "spec/assets/kitten.jpg".freeze, "spec/assets/prompt.txt".freeze, "spec/assets/searxng.json".freeze, "spec/ollama_chat/chat_spec.rb".freeze, "spec/ollama_chat/clipboard_spec.rb".freeze, "spec/ollama_chat/follow_chat_spec.rb".freeze, "spec/ollama_chat/information_spec.rb".freeze, "spec/ollama_chat/input_content_spec.rb".freeze, "spec/ollama_chat/kramdown_ansi_spec.rb".freeze, "spec/ollama_chat/message_editing_spec.rb".freeze, "spec/ollama_chat/message_list_spec.rb".freeze, "spec/ollama_chat/message_output_spec.rb".freeze, "spec/ollama_chat/model_handling_spec.rb".freeze, "spec/ollama_chat/parsing_spec.rb".freeze, "spec/ollama_chat/redis_cache_spec.rb".freeze, "spec/ollama_chat/server_socket_spec.rb".freeze, "spec/ollama_chat/source_fetching_spec.rb".freeze, "spec/ollama_chat/state_selectors_spec.rb".freeze, "spec/ollama_chat/switches_spec.rb".freeze, "spec/ollama_chat/think_control_spec.rb".freeze, "spec/ollama_chat/tools/browse_spec.rb".freeze, "spec/ollama_chat/tools/directory_structure_spec.rb".freeze, "spec/ollama_chat/tools/execute_grep_spec.rb".freeze, "spec/ollama_chat/tools/file_context_spec.rb".freeze, "spec/ollama_chat/tools/gem_path_lookup_spec.rb".freeze, "spec/ollama_chat/tools/get_current_weather_spec.rb".freeze, "spec/ollama_chat/tools/get_cve_spec.rb".freeze, "spec/ollama_chat/tools/get_endoflife_spec.rb".freeze, "spec/ollama_chat/tools/get_jira_issue_spec.rb".freeze, "spec/ollama_chat/tools/get_location_spec.rb".freeze, "spec/ollama_chat/tools/get_time_spec.rb".freeze, "spec/ollama_chat/tools/import_url_spec.rb".freeze, "spec/ollama_chat/tools/read_file_spec.rb".freeze, "spec/ollama_chat/tools/run_tests_spec.rb".freeze, "spec/ollama_chat/tools/search_web_spec.rb".freeze, "spec/ollama_chat/tools/vim_open_file_spec.rb".freeze, "spec/ollama_chat/tools/write_file_spec.rb".freeze, "spec/ollama_chat/utils/analyze_directory_spec.rb".freeze, "spec/ollama_chat/utils/cache_fetcher_spec.rb".freeze, "spec/ollama_chat/utils/fetcher_spec.rb".freeze, "spec/ollama_chat/utils/file_argument_spec.rb".freeze, "spec/ollama_chat/vim_spec.rb".freeze, "spec/ollama_chat/web_searching_spec.rb".freeze, "spec/spec_helper.rb".freeze, "tmp/.keep".freeze]
17
17
  s.homepage = "https://github.com/flori/ollama_chat".freeze
18
18
  s.licenses = ["MIT".freeze]
19
19
  s.rdoc_options = ["--title".freeze, "OllamaChat - A command-line interface (CLI) for interacting with an Ollama AI model.".freeze, "--main".freeze, "README.md".freeze]
20
20
  s.required_ruby_version = Gem::Requirement.new(">= 3.2".freeze)
21
21
  s.rubygems_version = "4.0.3".freeze
22
22
  s.summary = "A command-line interface (CLI) for interacting with an Ollama AI model.".freeze
23
- s.test_files = ["spec/assets/example.rb".freeze, "spec/ollama_chat/chat_spec.rb".freeze, "spec/ollama_chat/clipboard_spec.rb".freeze, "spec/ollama_chat/follow_chat_spec.rb".freeze, "spec/ollama_chat/information_spec.rb".freeze, "spec/ollama_chat/input_content_spec.rb".freeze, "spec/ollama_chat/kramdown_ansi_spec.rb".freeze, "spec/ollama_chat/message_editing_spec.rb".freeze, "spec/ollama_chat/message_list_spec.rb".freeze, "spec/ollama_chat/message_output_spec.rb".freeze, "spec/ollama_chat/model_handling_spec.rb".freeze, "spec/ollama_chat/parsing_spec.rb".freeze, "spec/ollama_chat/redis_cache_spec.rb".freeze, "spec/ollama_chat/server_socket_spec.rb".freeze, "spec/ollama_chat/source_fetching_spec.rb".freeze, "spec/ollama_chat/state_selectors_spec.rb".freeze, "spec/ollama_chat/switches_spec.rb".freeze, "spec/ollama_chat/think_control_spec.rb".freeze, "spec/ollama_chat/tools/browse_spec.rb".freeze, "spec/ollama_chat/tools/directory_structure_spec.rb".freeze, "spec/ollama_chat/tools/execute_grep_spec.rb".freeze, "spec/ollama_chat/tools/file_context_spec.rb".freeze, "spec/ollama_chat/tools/gem_path_lookup_spec.rb".freeze, "spec/ollama_chat/tools/get_current_weather_spec.rb".freeze, "spec/ollama_chat/tools/get_cve_spec.rb".freeze, "spec/ollama_chat/tools/get_endoflife_spec.rb".freeze, "spec/ollama_chat/tools/get_jira_issue_spec.rb".freeze, "spec/ollama_chat/tools/get_location_spec.rb".freeze, "spec/ollama_chat/tools/import_url_spec.rb".freeze, "spec/ollama_chat/tools/read_file_spec.rb".freeze, "spec/ollama_chat/tools/run_tests_spec.rb".freeze, "spec/ollama_chat/tools/search_web_spec.rb".freeze, "spec/ollama_chat/tools/vim_open_file_spec.rb".freeze, "spec/ollama_chat/tools/write_file_spec.rb".freeze, "spec/ollama_chat/utils/analyze_directory_spec.rb".freeze, "spec/ollama_chat/utils/cache_fetcher_spec.rb".freeze, "spec/ollama_chat/utils/fetcher_spec.rb".freeze, "spec/ollama_chat/utils/file_argument_spec.rb".freeze, "spec/ollama_chat/vim_spec.rb".freeze, "spec/ollama_chat/web_searching_spec.rb".freeze, "spec/spec_helper.rb".freeze]
23
+ s.test_files = ["spec/assets/example.rb".freeze, "spec/ollama_chat/chat_spec.rb".freeze, "spec/ollama_chat/clipboard_spec.rb".freeze, "spec/ollama_chat/follow_chat_spec.rb".freeze, "spec/ollama_chat/information_spec.rb".freeze, "spec/ollama_chat/input_content_spec.rb".freeze, "spec/ollama_chat/kramdown_ansi_spec.rb".freeze, "spec/ollama_chat/message_editing_spec.rb".freeze, "spec/ollama_chat/message_list_spec.rb".freeze, "spec/ollama_chat/message_output_spec.rb".freeze, "spec/ollama_chat/model_handling_spec.rb".freeze, "spec/ollama_chat/parsing_spec.rb".freeze, "spec/ollama_chat/redis_cache_spec.rb".freeze, "spec/ollama_chat/server_socket_spec.rb".freeze, "spec/ollama_chat/source_fetching_spec.rb".freeze, "spec/ollama_chat/state_selectors_spec.rb".freeze, "spec/ollama_chat/switches_spec.rb".freeze, "spec/ollama_chat/think_control_spec.rb".freeze, "spec/ollama_chat/tools/browse_spec.rb".freeze, "spec/ollama_chat/tools/directory_structure_spec.rb".freeze, "spec/ollama_chat/tools/execute_grep_spec.rb".freeze, "spec/ollama_chat/tools/file_context_spec.rb".freeze, "spec/ollama_chat/tools/gem_path_lookup_spec.rb".freeze, "spec/ollama_chat/tools/get_current_weather_spec.rb".freeze, "spec/ollama_chat/tools/get_cve_spec.rb".freeze, "spec/ollama_chat/tools/get_endoflife_spec.rb".freeze, "spec/ollama_chat/tools/get_jira_issue_spec.rb".freeze, "spec/ollama_chat/tools/get_location_spec.rb".freeze, "spec/ollama_chat/tools/get_time_spec.rb".freeze, "spec/ollama_chat/tools/import_url_spec.rb".freeze, "spec/ollama_chat/tools/read_file_spec.rb".freeze, "spec/ollama_chat/tools/run_tests_spec.rb".freeze, "spec/ollama_chat/tools/search_web_spec.rb".freeze, "spec/ollama_chat/tools/vim_open_file_spec.rb".freeze, "spec/ollama_chat/tools/write_file_spec.rb".freeze, "spec/ollama_chat/utils/analyze_directory_spec.rb".freeze, "spec/ollama_chat/utils/cache_fetcher_spec.rb".freeze, "spec/ollama_chat/utils/fetcher_spec.rb".freeze, "spec/ollama_chat/utils/file_argument_spec.rb".freeze, "spec/ollama_chat/vim_spec.rb".freeze, "spec/ollama_chat/web_searching_spec.rb".freeze, "spec/spec_helper.rb".freeze]
24
24
 
25
25
  s.specification_version = 4
26
26
 
@@ -11,7 +11,7 @@ describe OllamaChat::MessageList do
11
11
  ),
12
12
  prompts: double(
13
13
  location: 'You are at %{location_name} (%{location_decimal_degrees}),' \
14
- ' on %{localtime}, preferring %{units}'
14
+ ' preferring %{units}'
15
15
  ),
16
16
  system_prompts: double(
17
17
  assistant?: 'You are a helpful assistant.'
@@ -257,7 +257,7 @@ describe OllamaChat::MessageList do
257
257
  it 'can determine location for system prompt' do
258
258
  expect(chat).to receive(:location).and_return(double(on?: true))
259
259
  expect(list.send(:at_location)).to match(
260
- %r(You are at Berlin \(52.514127, 13.475211\), on))
260
+ %r(You are at Berlin \(52.514127, 13.475211\), ))
261
261
  end
262
262
 
263
263
  it 'can be converted int an Ollama::Message array' do
@@ -275,7 +275,7 @@ describe OllamaChat::MessageList do
275
275
  first = list.to_ary.first
276
276
  expect(first.role).to eq 'system'
277
277
  expect(first.content).to match(
278
- %r(You are at Berlin \(52.514127, 13.475211\), on))
278
+ %r(You are at Berlin \(52.514127, 13.475211\), ))
279
279
  end
280
280
 
281
281
  it 'can be converted int an Ollama::Message array with location without a system prompt' do
@@ -287,7 +287,7 @@ describe OllamaChat::MessageList do
287
287
  first = list.to_ary.first
288
288
  expect(first.role).to eq 'system'
289
289
  expect(first.content).to match(
290
- %r(You are a helpful assistant.\n\nYou are at Berlin \(52.514127, 13.475211\), on))
290
+ %r(You are a helpful assistant.\n\nYou are at Berlin \(52.514127, 13.475211\), ))
291
291
  end
292
292
 
293
293
 
@@ -24,11 +24,10 @@ describe OllamaChat::Tools::GetLocation do
24
24
  location_data = {
25
25
  latitude: 40.7128,
26
26
  longitude: -74.0060,
27
- time: '2023-05-15T14:30:00Z',
28
27
  units: 'metric'
29
28
  }
30
29
 
31
- chat_instance = double('Chat', location_data: location_data)
30
+ expect(chat).to receive(:location_data).and_return location_data
32
31
 
33
32
  tool_call = double(
34
33
  'ToolCall',
@@ -38,20 +37,15 @@ describe OllamaChat::Tools::GetLocation do
38
37
  )
39
38
  )
40
39
 
41
- result = described_class.new.execute(tool_call, chat: chat_instance)
40
+ result = described_class.new.execute(tool_call, chat:)
42
41
 
43
- # Parse the JSON result to verify content
44
- parsed_result = JSON.parse(result)
45
- expect(parsed_result['latitude']).to be_within(0.0001).of(40.7128)
46
- expect(parsed_result['longitude']).to be_within(0.0001).of(-74.0060)
47
- expect(parsed_result['time']).to eq '2023-05-15T14:30:00Z'
48
- expect(parsed_result['units']).to eq 'metric'
42
+ json = json_object(result)
43
+ expect(json.latitude).to be_within(0.0001).of(40.7128)
44
+ expect(json.longitude).to be_within(0.0001).of(-74.0060)
45
+ expect(json.units).to eq 'metric'
49
46
  end
50
47
 
51
48
  it 'can handle execution errors gracefully' do
52
- # Mock a chat instance that raises an error when accessing location_data
53
- chat_instance = double('Chat', location_data: nil)
54
-
55
49
  tool_call = double(
56
50
  'ToolCall',
57
51
  function: double(
@@ -62,14 +56,12 @@ describe OllamaChat::Tools::GetLocation do
62
56
 
63
57
  # Test that the method handles nil location_data gracefully
64
58
  expect {
65
- described_class.new.execute(tool_call, chat: chat_instance)
59
+ described_class.new.execute(tool_call, chat:)
66
60
  }.to_not raise_error
67
61
  end
68
62
 
69
63
  context 'when location_data is not available' do
70
64
  it 'returns valid JSON even with missing data' do
71
- chat_instance = double('Chat', location_data: nil)
72
-
73
65
  tool_call = double(
74
66
  'ToolCall',
75
67
  function: double(
@@ -78,7 +70,7 @@ describe OllamaChat::Tools::GetLocation do
78
70
  )
79
71
  )
80
72
 
81
- result = described_class.new.execute(tool_call, chat: chat_instance)
73
+ result = described_class.new.execute(tool_call, chat:)
82
74
  # Should still be valid JSON even if location_data is nil
83
75
  expect { JSON.parse(result) }.to_not raise_error
84
76
  end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe OllamaChat::Tools::GetTime do
4
+ let :chat do
5
+ OllamaChat::Chat.new(argv: chat_default_config)
6
+ end
7
+
8
+ connect_to_ollama_server
9
+
10
+ it 'can have name' do
11
+ expect(described_class.new.name).to eq 'get_time'
12
+ end
13
+
14
+ it 'can have tool' do
15
+ expect(described_class.new.tool).to be_a Ollama::Tool
16
+ end
17
+
18
+ it 'can be converted to hash' do
19
+ expect(described_class.new.to_hash).to be_a Hash
20
+ end
21
+
22
+ it 'can be executed successfully' do
23
+ tool_call = double(
24
+ 'ToolCall',
25
+ function: double(
26
+ name: 'get_time',
27
+ arguments: double()
28
+ )
29
+ )
30
+
31
+ result = described_class.new.execute(tool_call, chat:)
32
+
33
+ json = json_object(result)
34
+
35
+ expect(json.time).to match(
36
+ /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{2}:\d{2}\z/
37
+ )
38
+ end
39
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ollama_chat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.64
4
+ version: 0.0.65
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
@@ -490,6 +490,7 @@ extra_rdoc_files:
490
490
  - lib/ollama_chat/tools/get_endoflife.rb
491
491
  - lib/ollama_chat/tools/get_jira_issue.rb
492
492
  - lib/ollama_chat/tools/get_location.rb
493
+ - lib/ollama_chat/tools/get_time.rb
493
494
  - lib/ollama_chat/tools/import_url.rb
494
495
  - lib/ollama_chat/tools/read_file.rb
495
496
  - lib/ollama_chat/tools/run_tests.rb
@@ -558,6 +559,7 @@ files:
558
559
  - lib/ollama_chat/tools/get_endoflife.rb
559
560
  - lib/ollama_chat/tools/get_jira_issue.rb
560
561
  - lib/ollama_chat/tools/get_location.rb
562
+ - lib/ollama_chat/tools/get_time.rb
561
563
  - lib/ollama_chat/tools/import_url.rb
562
564
  - lib/ollama_chat/tools/read_file.rb
563
565
  - lib/ollama_chat/tools/run_tests.rb
@@ -624,6 +626,7 @@ files:
624
626
  - spec/ollama_chat/tools/get_endoflife_spec.rb
625
627
  - spec/ollama_chat/tools/get_jira_issue_spec.rb
626
628
  - spec/ollama_chat/tools/get_location_spec.rb
629
+ - spec/ollama_chat/tools/get_time_spec.rb
627
630
  - spec/ollama_chat/tools/import_url_spec.rb
628
631
  - spec/ollama_chat/tools/read_file_spec.rb
629
632
  - spec/ollama_chat/tools/run_tests_spec.rb
@@ -692,6 +695,7 @@ test_files:
692
695
  - spec/ollama_chat/tools/get_endoflife_spec.rb
693
696
  - spec/ollama_chat/tools/get_jira_issue_spec.rb
694
697
  - spec/ollama_chat/tools/get_location_spec.rb
698
+ - spec/ollama_chat/tools/get_time_spec.rb
695
699
  - spec/ollama_chat/tools/import_url_spec.rb
696
700
  - spec/ollama_chat/tools/read_file_spec.rb
697
701
  - spec/ollama_chat/tools/run_tests_spec.rb