clag 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/lib/clag/version.rb +1 -1
- data/vendor/gems/sublayer/lib/sublayer/capabilities/llm_assistance.rb +48 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1108e8ad1844399f3606f873dd03b65fb4131a130b829ba1332636ffa7bae74
|
4
|
+
data.tar.gz: c736a7bf0cd0e6fc3a6000b288c9b411dc53cf30857b61698bc6b28b82bb7a63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36ae1725de2b5d549d2f07f1401724ab82ea1fea9ba8622fb05d154f4008d53638b750a43654c7391c07f953e58d4dd9e6352519fead7b8182e5dbd8694078d8
|
7
|
+
data.tar.gz: 70d477e186eba030431e2e69d6b9cac4d88741d00a946dee73364e07e2e61f178cf39fd0619da059d3a80ff5b631d83bb2d53674cb8a84922ac163a99b9c784d
|
data/README.md
CHANGED
@@ -30,6 +30,23 @@ command with the help of an LLM!
|
|
30
30
|
* Select Gemini as your preferred LLM by setting CLAG\_LLM=gemini in your
|
31
31
|
environment
|
32
32
|
|
33
|
+
### Using Anthropic's Claude 3 Opus
|
34
|
+
|
35
|
+
* Get an API key from Anthropic at https://www.anthropic.com/
|
36
|
+
|
37
|
+
* Set your API key as ANTHROPIC\_API\_KEY in your environment
|
38
|
+
|
39
|
+
* Select Claude 3 Opus as your preferred LLM by setting CLAG\_LLM=claude in
|
40
|
+
your environment
|
41
|
+
|
42
|
+
### Using Groq on Mixtral
|
43
|
+
|
44
|
+
* Get an API key from https://console.groq.com/
|
45
|
+
|
46
|
+
* Set your API key as GROQ\_API\_KEY in your environment
|
47
|
+
|
48
|
+
* Select Groq as your preferred LLM by setting CLAG\_LLM=groq in your environment
|
49
|
+
|
33
50
|
## Usage
|
34
51
|
|
35
52
|
Currently support one command: "g".
|
data/lib/clag/version.rb
CHANGED
@@ -23,12 +23,60 @@ module Sublayer
|
|
23
23
|
generate_with_gemini
|
24
24
|
when "claude"
|
25
25
|
generate_with_claude
|
26
|
+
when "groq"
|
27
|
+
generate_with_groq
|
26
28
|
else
|
27
29
|
generate_with_openai
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
31
33
|
private
|
34
|
+
|
35
|
+
def generate_with_groq
|
36
|
+
system_prompt = <<-PROMPT
|
37
|
+
In this environment you have access to a set of tools you can use to answer the user's question.
|
38
|
+
|
39
|
+
You may call them like this:
|
40
|
+
<function_calls>
|
41
|
+
<invoke>
|
42
|
+
<tool_name>$TOOL_NAME</tool_name>
|
43
|
+
<parameters>
|
44
|
+
<command>value</command>
|
45
|
+
...
|
46
|
+
</parameters>
|
47
|
+
</invoke>
|
48
|
+
</function_calls>
|
49
|
+
|
50
|
+
Here are the tools available:
|
51
|
+
<tools>
|
52
|
+
#{self.class::OUTPUT_FUNCTION.to_xml}
|
53
|
+
</tools>
|
54
|
+
|
55
|
+
Respond only with valid xml.
|
56
|
+
The entire response should be wrapped in a <response> tag.
|
57
|
+
Any additional information not inside a tool call should go in a <scratch> tag.
|
58
|
+
PROMPT
|
59
|
+
|
60
|
+
response = HTTParty.post(
|
61
|
+
"https://api.groq.com/openai/v1/chat/completions",
|
62
|
+
headers: {
|
63
|
+
"Authorization": "Bearer #{ENV["GROQ_API_KEY"]}",
|
64
|
+
"Content-Type": "application/json"
|
65
|
+
},
|
66
|
+
body: {
|
67
|
+
"messages": [{"role": "user", "content": "#{system_prompt}\n#{prompt}"}],
|
68
|
+
"model": "mixtral-8x7b-32768"
|
69
|
+
}.to_json
|
70
|
+
)
|
71
|
+
|
72
|
+
text_containing_xml = JSON.parse(response.body).dig("choices", 0, "message", "content")
|
73
|
+
xml = text_containing_xml.match(/\<response\>(.*?)\<\/response\>/m).to_s
|
74
|
+
response_xml = Nokogiri::XML(xml)
|
75
|
+
function_output = response_xml.at_xpath("//response/function_calls/invoke/parameters/command").children.to_s
|
76
|
+
|
77
|
+
return function_output
|
78
|
+
end
|
79
|
+
|
32
80
|
def generate_with_claude
|
33
81
|
system_prompt = <<-PROMPT
|
34
82
|
In this environment you have access to a set of tools you can use to answer the user's question.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clag
|
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
|
- Scott Werner
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cli-kit
|