sublayer 0.0.1 → 0.0.2

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: cb6358bd6d422e0f622348c8eaf86d80b42083e22cbae800f7a8d9afc4805a76
4
+ data.tar.gz: ddce248ed595c54991d725a44f5c52db3c548db4743be50562f6931ec5cd2912
5
5
  SHA512:
6
- metadata.gz: df71cd627df49a5b76a631810137fb639e5c936a2a9f2516ccc90ede301428ea00f6fce79045b37539ff89a02f3bca1b69f4fd53816f91c1cd9aee153760d482
7
- data.tar.gz: 694f971637fd0609b6a0b07f3a178d7f3b51d42820b51a4e282c360a39b806541f8534976caa320a065e345b02f32069865da9e88de10ae31000d1697cc52dec
6
+ metadata.gz: 96d7ba5dd91cdf4d4107c4017f0e572bdb483450816c6838b5d2f80e9ee9849501f3f522431b19c72afb2e9a019f76556999d4d5c2999987019d78b9f6251eeb
7
+ data.tar.gz: 726950c1e36fe621fdf16da04e835e241c41fe648dfb7404ab148cd5b0a3567eb495ad620a9ba6ebe8d4910b9d42eea87073294da83fb19814422d59b843ba31
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
 
@@ -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.2"
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.2
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-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-openai