tiny_ollama 1.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tiny_ollama.rb +1 -25
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36c40168a27181184b384503b7e1ad46186bb271f22bd7784ad817d069c9edcb
4
- data.tar.gz: aff09cee4326797ed6020053bc1d35d1f7f82d0a86667ada0525b8b0180a2149
3
+ metadata.gz: ca4fe9ba0bb0854333e7c1e62b6f0deb0e1b944e5f406086c7148524743521b7
4
+ data.tar.gz: 47f4a7b71302ea587ad84fd37b9c9ae2cd3d9514ee8b20eb2fe01128f96e42ab
5
5
  SHA512:
6
- metadata.gz: d35d657124e45275b31e9a08d01ef05b081e332cd7db1d542e43e2d3c1bcc1fe96ab93ad1b689ec5e481eb4a4395e39cbd92722e1cb139caa07481edfcd53cfa
7
- data.tar.gz: 3eec3df3884bc4545215c2bde92fb0a2336cdf84e704e2c2611ec4aaed5c5343be903014674ed54af296049566701387e5b4f742c773166b04523ef79c6c1c42
6
+ metadata.gz: dab2b666565a058ff3e48080b9de089316fd0cb5be6b7dc764f6ac6ef3e30de351f7bf2de6fb0de0de14a7a221ca81a3a0e1c713d74b6a851bb74cfc008d9e90
7
+ data.tar.gz: e765aee90aef074d6b5cffd9b71da0a90fe20b443feabc305909fd739c07192446bcde7fb46bfab9f888489a632f76e15933ac5c9eb59db6dd02e209182ec35f
data/lib/tiny_ollama.rb CHANGED
@@ -25,30 +25,6 @@ class TinyOllama
25
25
  @format = format
26
26
  end
27
27
 
28
- # sends a request to POST /api/generate
29
- def generate(prompt)
30
- request_body = {
31
- model: @model,
32
- prompt: prompt,
33
- stream: @stream,
34
- keep_alive: @keep_alive,
35
- options: {
36
- num_ctx: @context_size,
37
- }.merge(@format ? { format: @format } : {})
38
- }.to_json
39
-
40
- uri = URI("http://#{@host}:#{@port}/api/generate")
41
- headers = { 'Content-Type' => 'application/json' }
42
- response = Net::HTTP.post(uri, request_body, headers)
43
-
44
- # Handle potential errors (e.g., non-200 responses)
45
- unless response.is_a?(Net::HTTPSuccess)
46
- raise TinyOllamaModelError.new("Ollama API Error: #{response.code} - #{response.body}")
47
- end
48
-
49
- JSON.parse(response.body)['response']
50
- end
51
-
52
28
  # sends a request to POST /api/chat
53
29
  #
54
30
  # messages: an array of hashes in the following format:
@@ -73,7 +49,7 @@ class TinyOllama
73
49
  #
74
50
  # NOTE: the messages parameter needs to include a system message if you want
75
51
  # to override the model's default instructions
76
- def chat(messages)
52
+ def prompt(messages)
77
53
  request_body = {
78
54
  model: @model,
79
55
  messages: messages,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_ollama
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Lunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-07 00:00:00.000000000 Z
11
+ date: 2024-07-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: a tiny gem for using ollama's generate and chat endpoints
14
14
  email: jefflunt@gmail.com