ollama_chat 0.0.3 → 0.0.4
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 +4 -4
- data/.gitignore +1 -0
- data/CHANGES.md +15 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/config/searxng/settings.yml +2583 -0
- data/docker-compose.yml +21 -0
- data/lib/ollama_chat/chat.rb +3 -2
- data/lib/ollama_chat/information.rb +2 -0
- data/lib/ollama_chat/ollama_chat_config/default_config.yml +7 -0
- data/lib/ollama_chat/source_fetching.rb +0 -33
- data/lib/ollama_chat/version.rb +1 -1
- data/lib/ollama_chat/web_searching.rb +60 -0
- data/lib/ollama_chat.rb +1 -0
- data/ollama_chat.gemspec +6 -6
- data/spec/assets/searxng.json +111 -0
- data/spec/ollama_chat/chat_spec.rb +3 -1
- data/spec/ollama_chat/source_fetching_spec.rb +0 -9
- data/spec/ollama_chat/web_searching_spec.rb +29 -0
- metadata +8 -2
data/docker-compose.yml
CHANGED
@@ -1,10 +1,31 @@
|
|
1
1
|
services:
|
2
2
|
redis:
|
3
|
+
container_name: redis
|
3
4
|
image: valkey/valkey:7.2.8-alpine
|
4
5
|
restart: unless-stopped
|
5
6
|
ports: [ "127.0.0.1:9736:6379" ]
|
6
7
|
volumes:
|
7
8
|
- "redis-data:/data:delegated"
|
8
9
|
- "./redis/redis.conf:/etc/redis.conf"
|
10
|
+
searxng:
|
11
|
+
container_name: searxng
|
12
|
+
image: searxng/searxng:latest
|
13
|
+
ports:
|
14
|
+
- "127.0.0.1:8088:8080"
|
15
|
+
restart: unless-stopped
|
16
|
+
cap_drop:
|
17
|
+
- ALL
|
18
|
+
cap_add:
|
19
|
+
- CHOWN
|
20
|
+
- SETGID
|
21
|
+
- SETUID
|
22
|
+
- DAC_OVERRIDE
|
23
|
+
logging:
|
24
|
+
driver: "json-file"
|
25
|
+
options:
|
26
|
+
max-size: "1m"
|
27
|
+
max-file: "1"
|
28
|
+
volumes:
|
29
|
+
- "./config/searxng:/etc/searxng"
|
9
30
|
volumes:
|
10
31
|
redis-data:
|
data/lib/ollama_chat/chat.rb
CHANGED
@@ -19,6 +19,7 @@ class OllamaChat::Chat
|
|
19
19
|
include OllamaChat::ModelHandling
|
20
20
|
include OllamaChat::Parsing
|
21
21
|
include OllamaChat::SourceFetching
|
22
|
+
include OllamaChat::WebSearching
|
22
23
|
include OllamaChat::Dialog
|
23
24
|
include OllamaChat::Information
|
24
25
|
include OllamaChat::Clipboard
|
@@ -201,7 +202,7 @@ class OllamaChat::Chat
|
|
201
202
|
content = embed($1) or next
|
202
203
|
when %r(^/web\s+(?:(\d+)\s+)?(.+))
|
203
204
|
parse_content = false
|
204
|
-
urls = search_web($2, $1.to_i)
|
205
|
+
urls = search_web($2, $1.to_i) or next
|
205
206
|
urls.each do |url|
|
206
207
|
fetch_source(url) { |url_io| embed_source(url_io, url) }
|
207
208
|
end
|
@@ -392,7 +393,7 @@ class OllamaChat::Chat
|
|
392
393
|
Documentrix::Documents::RedisCache.new(
|
393
394
|
prefix: 'Expiring-',
|
394
395
|
url:,
|
395
|
-
ex: config.redis.expiring.ex,
|
396
|
+
ex: config.redis.expiring.ex?.to_i,
|
396
397
|
)
|
397
398
|
end
|
398
399
|
end
|
@@ -28,6 +28,7 @@ module OllamaChat::Information
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def info
|
31
|
+
STDOUT.puts "Running ollama_chat version: #{bold(OllamaChat::VERSION)}"
|
31
32
|
STDOUT.puts "Connected to ollama server version: #{bold(server_version)}"
|
32
33
|
STDOUT.puts "Current model is #{bold{@model}}."
|
33
34
|
if @model_options.present?
|
@@ -47,6 +48,7 @@ module OllamaChat::Information
|
|
47
48
|
stream.show
|
48
49
|
location.show
|
49
50
|
STDOUT.puts "Document policy for references in user text: #{bold{@document_policy}}"
|
51
|
+
STDOUT.puts "Currently selected search engine is #{bold(search_engine)}."
|
50
52
|
if @voice.on?
|
51
53
|
STDOUT.puts "Using voice #{bold{@current_voice}} to speak."
|
52
54
|
end
|
@@ -60,3 +60,10 @@ request_headers:
|
|
60
60
|
Accept: 'text/*,application/*,image/*'
|
61
61
|
ssl_no_verify: []
|
62
62
|
copy: pbcopy
|
63
|
+
web_search:
|
64
|
+
use: duckduckgo
|
65
|
+
engines:
|
66
|
+
duckduckgo:
|
67
|
+
url: 'https://www.duckduckgo.com/html/?q=%{query}'
|
68
|
+
searxng:
|
69
|
+
url: 'http://localhost:8088/search?q=%{query}&format=json'
|
@@ -141,37 +141,4 @@ module OllamaChat::SourceFetching
|
|
141
141
|
summarize(source)
|
142
142
|
end
|
143
143
|
end
|
144
|
-
|
145
|
-
def search_web(query, n = nil)
|
146
|
-
if l = @messages.at_location.full?
|
147
|
-
query += " #{l}"
|
148
|
-
end
|
149
|
-
n = n.to_i.clamp(1..)
|
150
|
-
query = URI.encode_uri_component(query)
|
151
|
-
url = "https://www.duckduckgo.com/html/?q=#{query}"
|
152
|
-
OllamaChat::Utils::Fetcher.get(
|
153
|
-
url,
|
154
|
-
headers: config.request_headers?.to_h,
|
155
|
-
debug: config.debug
|
156
|
-
) do |tmp|
|
157
|
-
result = []
|
158
|
-
doc = Nokogiri::HTML(tmp)
|
159
|
-
doc.css('.results_links').each do |link|
|
160
|
-
if n > 0
|
161
|
-
url = link.css('.result__a').first&.[]('href')
|
162
|
-
url.sub!(%r(\A(//duckduckgo\.com)?/l/\?uddg=), '')
|
163
|
-
url.sub!(%r(&rut=.*), '')
|
164
|
-
url = URI.decode_uri_component(url)
|
165
|
-
url = URI.parse(url)
|
166
|
-
url.host =~ /duckduckgo\.com/ and next
|
167
|
-
links.add(url.to_s)
|
168
|
-
result << url
|
169
|
-
n -= 1
|
170
|
-
else
|
171
|
-
break
|
172
|
-
end
|
173
|
-
end
|
174
|
-
result
|
175
|
-
end
|
176
|
-
end
|
177
144
|
end
|
data/lib/ollama_chat/version.rb
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
module OllamaChat::WebSearching
|
2
|
+
def search_web(query, n = nil)
|
3
|
+
l = @messages.at_location.full? and query += " #{l}"
|
4
|
+
n = n.to_i.clamp(1..)
|
5
|
+
query = URI.encode_uri_component(query)
|
6
|
+
search_command = :"search_web_with_#{search_engine}"
|
7
|
+
if respond_to?(search_command, true)
|
8
|
+
send(search_command, query, n)
|
9
|
+
else
|
10
|
+
STDOUT.puts "Search engine #{bold{search_engine}} not implemented!"
|
11
|
+
nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def search_engine
|
18
|
+
config.web_search.use
|
19
|
+
end
|
20
|
+
|
21
|
+
def search_web_with_searxng(query, n)
|
22
|
+
url = config.web_search.engines.searxng.url % { query: }
|
23
|
+
OllamaChat::Utils::Fetcher.get(
|
24
|
+
url,
|
25
|
+
headers: config.request_headers?.to_h,
|
26
|
+
debug: config.debug
|
27
|
+
) do |tmp|
|
28
|
+
data = JSON.parse(tmp.read, object_class: JSON::GenericObject)
|
29
|
+
data.results.first(n).map(&:url)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def search_web_with_duckduckgo(query, n)
|
34
|
+
url = config.web_search.engines.duckduckgo.url % { query: }
|
35
|
+
OllamaChat::Utils::Fetcher.get(
|
36
|
+
url,
|
37
|
+
headers: config.request_headers?.to_h,
|
38
|
+
debug: config.debug
|
39
|
+
) do |tmp|
|
40
|
+
result = []
|
41
|
+
doc = Nokogiri::HTML(tmp)
|
42
|
+
doc.css('.results_links').each do |link|
|
43
|
+
if n > 0
|
44
|
+
url = link.css('.result__a').first&.[]('href')
|
45
|
+
url.sub!(%r(\A(//duckduckgo\.com)?/l/\?uddg=), '')
|
46
|
+
url.sub!(%r(&rut=.*), '')
|
47
|
+
url = URI.decode_uri_component(url)
|
48
|
+
url = URI.parse(url)
|
49
|
+
url.host =~ /duckduckgo\.com/ and next
|
50
|
+
links.add(url.to_s)
|
51
|
+
result << url
|
52
|
+
n -= 1
|
53
|
+
else
|
54
|
+
break
|
55
|
+
end
|
56
|
+
end
|
57
|
+
result
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/ollama_chat.rb
CHANGED
@@ -13,6 +13,7 @@ require 'ollama_chat/message_list'
|
|
13
13
|
require 'ollama_chat/model_handling'
|
14
14
|
require 'ollama_chat/parsing'
|
15
15
|
require 'ollama_chat/source_fetching'
|
16
|
+
require 'ollama_chat/web_searching'
|
16
17
|
require 'ollama_chat/dialog'
|
17
18
|
require 'ollama_chat/information'
|
18
19
|
require 'ollama_chat/clipboard'
|
data/ollama_chat.gemspec
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: ollama_chat 0.0.
|
2
|
+
# stub: ollama_chat 0.0.4 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "ollama_chat".freeze
|
6
|
-
s.version = "0.0.
|
6
|
+
s.version = "0.0.4".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]
|
10
10
|
s.authors = ["Florian Frank".freeze]
|
11
|
-
s.date = "2025-02-
|
11
|
+
s.date = "2025-02-21"
|
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]
|
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/dialog.rb".freeze, "lib/ollama_chat/document_cache.rb".freeze, "lib/ollama_chat/follow_chat.rb".freeze, "lib/ollama_chat/information.rb".freeze, "lib/ollama_chat/message_list.rb".freeze, "lib/ollama_chat/message_type.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/source_fetching.rb".freeze, "lib/ollama_chat/switches.rb".freeze, "lib/ollama_chat/utils.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/version.rb".freeze]
|
16
|
-
s.files = [".all_images.yml".freeze, ".envrc".freeze, ".gitignore".freeze, "CHANGES.md".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/ollama_chat".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/dialog.rb".freeze, "lib/ollama_chat/document_cache.rb".freeze, "lib/ollama_chat/follow_chat.rb".freeze, "lib/ollama_chat/information.rb".freeze, "lib/ollama_chat/message_list.rb".freeze, "lib/ollama_chat/message_type.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/source_fetching.rb".freeze, "lib/ollama_chat/switches.rb".freeze, "lib/ollama_chat/utils.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/version.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/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/kitten.jpg".freeze, "spec/assets/prompt.txt".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/message_list_spec.rb".freeze, "spec/ollama_chat/model_handling_spec.rb".freeze, "spec/ollama_chat/parsing_spec.rb".freeze, "spec/ollama_chat/source_fetching_spec.rb".freeze, "spec/ollama_chat/switches_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/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/dialog.rb".freeze, "lib/ollama_chat/document_cache.rb".freeze, "lib/ollama_chat/follow_chat.rb".freeze, "lib/ollama_chat/information.rb".freeze, "lib/ollama_chat/message_list.rb".freeze, "lib/ollama_chat/message_type.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/source_fetching.rb".freeze, "lib/ollama_chat/switches.rb".freeze, "lib/ollama_chat/utils.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/version.rb".freeze, "lib/ollama_chat/web_searching.rb".freeze]
|
16
|
+
s.files = [".all_images.yml".freeze, ".envrc".freeze, ".gitignore".freeze, "CHANGES.md".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/ollama_chat".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/dialog.rb".freeze, "lib/ollama_chat/document_cache.rb".freeze, "lib/ollama_chat/follow_chat.rb".freeze, "lib/ollama_chat/information.rb".freeze, "lib/ollama_chat/message_list.rb".freeze, "lib/ollama_chat/message_type.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/source_fetching.rb".freeze, "lib/ollama_chat/switches.rb".freeze, "lib/ollama_chat/utils.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/version.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/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/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/message_list_spec.rb".freeze, "spec/ollama_chat/model_handling_spec.rb".freeze, "spec/ollama_chat/parsing_spec.rb".freeze, "spec/ollama_chat/source_fetching_spec.rb".freeze, "spec/ollama_chat/switches_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/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.1".freeze)
|
21
21
|
s.rubygems_version = "3.6.2".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/message_list_spec.rb".freeze, "spec/ollama_chat/model_handling_spec.rb".freeze, "spec/ollama_chat/parsing_spec.rb".freeze, "spec/ollama_chat/source_fetching_spec.rb".freeze, "spec/ollama_chat/switches_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/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/message_list_spec.rb".freeze, "spec/ollama_chat/model_handling_spec.rb".freeze, "spec/ollama_chat/parsing_spec.rb".freeze, "spec/ollama_chat/source_fetching_spec.rb".freeze, "spec/ollama_chat/switches_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/web_searching_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
24
24
|
|
25
25
|
s.specification_version = 4
|
26
26
|
|
@@ -0,0 +1,111 @@
|
|
1
|
+
{
|
2
|
+
"query": "foo",
|
3
|
+
"number_of_results": 0,
|
4
|
+
"results": [
|
5
|
+
{
|
6
|
+
"url": "https://en.wikipedia.org/wiki/Foo_Fighters",
|
7
|
+
"title": "Foo Fighters - Wikipedia",
|
8
|
+
"content": "The Foo Fighters are an American rock band formed in Seattle in 1994. Initially founded as a one-man project by former Nirvana drummer Dave Grohl, the band comprises vocalist/guitarist Grohl, bassist Nate Mendel, guitarist Pat Smear, guitarist Chris Shiflett, keyboardist Rami Jaffee and drummer Josh Freese.Guitarist Franz Stahl and drummers William Goldsmith and Taylor Hawkins are former ...",
|
9
|
+
"publishedDate": null,
|
10
|
+
"thumbnail": null,
|
11
|
+
"engine": "brave",
|
12
|
+
"template": "default.html",
|
13
|
+
"parsed_url": [
|
14
|
+
"https",
|
15
|
+
"en.wikipedia.org",
|
16
|
+
"/wiki/Foo_Fighters",
|
17
|
+
"",
|
18
|
+
"",
|
19
|
+
""
|
20
|
+
],
|
21
|
+
"engines": [
|
22
|
+
"startpage",
|
23
|
+
"brave",
|
24
|
+
"google",
|
25
|
+
"duckduckgo"
|
26
|
+
],
|
27
|
+
"positions": [
|
28
|
+
2,
|
29
|
+
1,
|
30
|
+
2,
|
31
|
+
1
|
32
|
+
],
|
33
|
+
"score": 12.0,
|
34
|
+
"category": "general"
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"url": "https://www.foofighters.com",
|
38
|
+
"title": "Home - Foo Fighters",
|
39
|
+
"content": "Official website of Foo Fighters",
|
40
|
+
"publishedDate": "2023-04-19T00:00:00",
|
41
|
+
"thumbnail": null,
|
42
|
+
"engine": "brave",
|
43
|
+
"template": "default.html",
|
44
|
+
"parsed_url": [
|
45
|
+
"https",
|
46
|
+
"www.foofighters.com",
|
47
|
+
"",
|
48
|
+
"",
|
49
|
+
"",
|
50
|
+
""
|
51
|
+
],
|
52
|
+
"engines": [
|
53
|
+
"startpage",
|
54
|
+
"brave",
|
55
|
+
"google",
|
56
|
+
"duckduckgo"
|
57
|
+
],
|
58
|
+
"positions": [
|
59
|
+
1,
|
60
|
+
2,
|
61
|
+
7,
|
62
|
+
2
|
63
|
+
],
|
64
|
+
"score": 8.571428571428571,
|
65
|
+
"category": "general"
|
66
|
+
},
|
67
|
+
{
|
68
|
+
"url": "https://www.dictionary.com/e/tech-science/foo/",
|
69
|
+
"title": "foo | Meaning & Origin | Dictionary.com",
|
70
|
+
"content": "\"Foo was here\" was a popular piece of graffiti drawn by Australian soldiers in WWII, and possibly even WWI, that depicts a little man poking his head and large nose over the wall à la Kilroy. While the origins of this foo are unclear, it appears to be unrelated to Holman's foo.",
|
71
|
+
"publishedDate": "2022-07-04T00:00:00",
|
72
|
+
"thumbnail": "",
|
73
|
+
"engine": "brave",
|
74
|
+
"template": "default.html",
|
75
|
+
"parsed_url": [
|
76
|
+
"https",
|
77
|
+
"www.dictionary.com",
|
78
|
+
"/e/tech-science/foo/",
|
79
|
+
"",
|
80
|
+
"",
|
81
|
+
""
|
82
|
+
],
|
83
|
+
"engines": [
|
84
|
+
"brave",
|
85
|
+
"duckduckgo"
|
86
|
+
],
|
87
|
+
"positions": [
|
88
|
+
13,
|
89
|
+
1
|
90
|
+
],
|
91
|
+
"score": 2.1538461538461537,
|
92
|
+
"category": "general"
|
93
|
+
}
|
94
|
+
],
|
95
|
+
"suggestions": [
|
96
|
+
"foo fighters - everlong",
|
97
|
+
"Foo meaning",
|
98
|
+
"Foo Fighters WW2",
|
99
|
+
"Foo Fighters - Learn to Fly",
|
100
|
+
"foo fighters - the colour and the shape",
|
101
|
+
"Foo Fighters tour 2024",
|
102
|
+
"Foo programming",
|
103
|
+
"Foo word"
|
104
|
+
],
|
105
|
+
"unresponsive_engines": [
|
106
|
+
[
|
107
|
+
"qwant",
|
108
|
+
"Suspended: CAPTCHA"
|
109
|
+
]
|
110
|
+
]
|
111
|
+
}
|
@@ -71,6 +71,7 @@ RSpec.describe OllamaChat::Chat do
|
|
71
71
|
expect(STDOUT).to receive(:puts).
|
72
72
|
with(
|
73
73
|
/
|
74
|
+
Running\ ollama_chat\ version|
|
74
75
|
Connected\ to\ ollama\ server|
|
75
76
|
Current\ model|
|
76
77
|
Options|
|
@@ -80,7 +81,8 @@ RSpec.describe OllamaChat::Chat do
|
|
80
81
|
output\ content|
|
81
82
|
Streaming|
|
82
83
|
Location|
|
83
|
-
Document\ policy
|
84
|
+
Document\ policy|
|
85
|
+
Currently\ selected\ search\ engine
|
84
86
|
/x
|
85
87
|
).at_least(1)
|
86
88
|
expect(chat.info).to be_nil
|
@@ -36,13 +36,4 @@ RSpec.describe OllamaChat::SourceFetching do
|
|
36
36
|
'This source was now embedded: ./spec/assets/example.html'
|
37
37
|
)
|
38
38
|
end
|
39
|
-
|
40
|
-
it 'can search web' do
|
41
|
-
stub_request(:get, "https://www.duckduckgo.com/html/?q=foo").
|
42
|
-
with(headers: { 'Host'=>'www.duckduckgo.com' }).
|
43
|
-
to_return(status: 200, body: asset_content('duckduckgo.html'), headers: {})
|
44
|
-
expect(chat.search_web('foo').first.to_s).to eq(
|
45
|
-
'https://en.wikipedia.org/wiki/Foo_Fighters'
|
46
|
-
)
|
47
|
-
end
|
48
39
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe OllamaChat::WebSearching do
|
4
|
+
let :chat do
|
5
|
+
OllamaChat::Chat.new
|
6
|
+
end
|
7
|
+
|
8
|
+
connect_to_ollama_server
|
9
|
+
|
10
|
+
it 'can search web with duckduckgo' do
|
11
|
+
expect(chat).to receive(:search_engine).and_return 'duckduckgo'
|
12
|
+
stub_request(:get, 'https://www.duckduckgo.com/html/?q=foo').
|
13
|
+
with(headers: { 'Host'=>'www.duckduckgo.com' }).
|
14
|
+
to_return(status: 200, body: asset_content('duckduckgo.html'), headers: {})
|
15
|
+
expect(chat.search_web('foo').first.to_s).to eq(
|
16
|
+
'https://en.wikipedia.org/wiki/Foo_Fighters'
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'can search web with searxng' do
|
21
|
+
expect(chat).to receive(:search_engine).and_return 'searxng'
|
22
|
+
stub_request(:get, 'http://localhost:8088/search?format=json&language=en&q=foo').
|
23
|
+
with(headers: { 'Host'=>'localhost:8088' }).
|
24
|
+
to_return(status: 200, body: asset_content('searxng.json'), headers: {})
|
25
|
+
expect(chat.search_web('foo').first.to_s).to eq(
|
26
|
+
'https://en.wikipedia.org/wiki/Foo_Fighters'
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ollama_chat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-02-
|
10
|
+
date: 2025-02-21 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: gem_hadar
|
@@ -377,6 +377,7 @@ extra_rdoc_files:
|
|
377
377
|
- lib/ollama_chat/utils/fetcher.rb
|
378
378
|
- lib/ollama_chat/utils/file_argument.rb
|
379
379
|
- lib/ollama_chat/version.rb
|
380
|
+
- lib/ollama_chat/web_searching.rb
|
380
381
|
files:
|
381
382
|
- ".all_images.yml"
|
382
383
|
- ".envrc"
|
@@ -387,6 +388,7 @@ files:
|
|
387
388
|
- Rakefile
|
388
389
|
- VERSION
|
389
390
|
- bin/ollama_chat
|
391
|
+
- config/searxng/settings.yml
|
390
392
|
- docker-compose.yml
|
391
393
|
- lib/ollama_chat.rb
|
392
394
|
- lib/ollama_chat/chat.rb
|
@@ -409,6 +411,7 @@ files:
|
|
409
411
|
- lib/ollama_chat/utils/fetcher.rb
|
410
412
|
- lib/ollama_chat/utils/file_argument.rb
|
411
413
|
- lib/ollama_chat/version.rb
|
414
|
+
- lib/ollama_chat/web_searching.rb
|
412
415
|
- ollama_chat.gemspec
|
413
416
|
- redis/redis.conf
|
414
417
|
- spec/assets/api_show.json
|
@@ -426,6 +429,7 @@ files:
|
|
426
429
|
- spec/assets/example.xml
|
427
430
|
- spec/assets/kitten.jpg
|
428
431
|
- spec/assets/prompt.txt
|
432
|
+
- spec/assets/searxng.json
|
429
433
|
- spec/ollama_chat/chat_spec.rb
|
430
434
|
- spec/ollama_chat/clipboard_spec.rb
|
431
435
|
- spec/ollama_chat/follow_chat_spec.rb
|
@@ -438,6 +442,7 @@ files:
|
|
438
442
|
- spec/ollama_chat/utils/cache_fetcher_spec.rb
|
439
443
|
- spec/ollama_chat/utils/fetcher_spec.rb
|
440
444
|
- spec/ollama_chat/utils/file_argument_spec.rb
|
445
|
+
- spec/ollama_chat/web_searching_spec.rb
|
441
446
|
- spec/spec_helper.rb
|
442
447
|
- tmp/.keep
|
443
448
|
homepage: https://github.com/flori/ollama_chat
|
@@ -479,4 +484,5 @@ test_files:
|
|
479
484
|
- spec/ollama_chat/utils/cache_fetcher_spec.rb
|
480
485
|
- spec/ollama_chat/utils/fetcher_spec.rb
|
481
486
|
- spec/ollama_chat/utils/file_argument_spec.rb
|
487
|
+
- spec/ollama_chat/web_searching_spec.rb
|
482
488
|
- spec/spec_helper.rb
|