sublayer 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49d6bc9e7a56b5f5b7cb47aa3c46bfd5c30fe7ff5927b7b391fe370d70b8e4e3
4
- data.tar.gz: e54f5e28724f4c8fb8af83b13bd7a71de005266511b275540955376d91a2b6a9
3
+ metadata.gz: 3ad3ab932b7da063821a5f9047d6a58e895fb5db1b34ca71ef8a7742ccddd7dc
4
+ data.tar.gz: ef15f73fd28e091667f1316f60b5b0c882240d1897f57b806e001dc3c885e3cf
5
5
  SHA512:
6
- metadata.gz: df71cd627df49a5b76a631810137fb639e5c936a2a9f2516ccc90ede301428ea00f6fce79045b37539ff89a02f3bca1b69f4fd53816f91c1cd9aee153760d482
7
- data.tar.gz: 694f971637fd0609b6a0b07f3a178d7f3b51d42820b51a4e282c360a39b806541f8534976caa320a065e345b02f32069865da9e88de10ae31000d1697cc52dec
6
+ metadata.gz: b606328f717c6312fde90b91b6bed4d58cacc0ae266199a6287b72f4da8aa0fcc3c01ffb28aff19043b81c2e7a3891e628db9c8f373cb14e359385e617e4bd76
7
+ data.tar.gz: b4fec2575647858bae068d41117e5842438e5ec8d1e8303a12a613cec913b11d6b8ff261fd84d276b874c19c4f1aea0fef3d94748bbebc443134ba0cb84c91e8
data/README.md CHANGED
@@ -65,14 +65,18 @@ Sublayer.configuration.ai_provider = Sublayer::Providers::Groq
65
65
  Sublayer.configuration.ai_model = "mixtral-8x7b-32768"
66
66
  ```
67
67
 
68
- ### Local
68
+ ### Local (Experimental with Hermes2)
69
+
70
+ *Tested against the latest [Hermes 2 Mistral
71
+ Model](https://huggingface.co/NousResearch/Hermes-2-Pro-Mistral-7B-GGUF)*
69
72
 
70
73
  Support for running a local model and serving an API on https://localhost:8080
71
74
 
72
75
  The simplest way to do this is to download
73
76
  [llamafile](https://github.com/Mozilla-Ocho/llamafile) and download one of the
74
- server llamafiles they provide. We've also tested with [this Mixtral
75
- model](https://huggingface.co/NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO-GGUF) from
77
+ server llamafiles they provide.
78
+
79
+ We've also tested with [Hermes 2 Mistral](https://huggingface.co/NousResearch/Hermes-2-Pro-Mistral-7B-GGUF) from
76
80
  [Nous
77
81
  Research](https://nousresearch.com/).
78
82
 
@@ -1,4 +1,3 @@
1
- require "pry"
2
1
  module Sublayer
3
2
  module Generators
4
3
  class Base
@@ -4,29 +4,25 @@
4
4
  module Sublayer
5
5
  module Providers
6
6
  class Local
7
- def initialize(prompt:, output_adapter:)
7
+ def self.call(prompt:, output_adapter:)
8
8
  system_prompt = <<-PROMPT
9
- In this environment you have access to a set of tools you can use to answer the user's question.
10
-
11
- You may call them like this:
12
- <function_calls>
13
- <invoke>
14
- <tool_name>$TOOL_NAME</tool_name>
15
- <parameters>
16
- <#{output_adapter.name}>value</#{output_adapter.name}>
17
- ...
18
- </parameters>
19
- </invoke>
20
- </function_calls>
21
-
22
- Here are the tools available:
9
+ You are a function calling AI agent
10
+ You can call only one function at a time
11
+ You are provided with function signatures within <tools></tools> XML tags.
12
+
13
+ Please call a function and wait for results to be provided to you in the next iteration.
14
+ Don't make assumptions about what values to plug into function arguments.
15
+
16
+ Here are the available tools:
23
17
  <tools>
24
- #{output_adapter.to_xml}
18
+ #{output_adapter.to_hash.to_json}
25
19
  </tools>
26
20
 
27
- Respond only with valid xml.
28
- The entire response should be wrapped in a <response> tag.
29
- Any additional information not inside a tool call should go in a <scratch> tag.
21
+ For the function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags as follows:
22
+
23
+ <tool_call>
24
+ {"arguments": <args-dict>, "name": <function-name>}
25
+ </tool_call>
30
26
  PROMPT
31
27
 
32
28
  response = HTTParty.post(
@@ -45,9 +41,8 @@ module Sublayer
45
41
  )
46
42
 
47
43
  text_containing_xml = JSON.parse(response.body).dig("choices", 0, "message", "content")
48
- xml = text_containing_xml.match(/\<response\>(.*?)\<\/response\>/m).to_s
49
- response_xml = ::Nokogiri::XML(xml)
50
- function_output = response_xml.at_xpath("//parameters/#{output_adapter.name}").children.to_s
44
+ results = JSON.parse(::Nokogiri::XML(text_containing_xml).at_xpath("//tool_call").children.to_s.strip)
45
+ function_output = results["arguments"][output_adapter.name]
51
46
 
52
47
  return function_output
53
48
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sublayer
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sublayer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Werner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-12 00:00:00.000000000 Z
11
+ date: 2024-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-openai