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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f35aebcc5178b31dd6c9b83463a433ed363538234795557ef5b57d02608e1478
4
- data.tar.gz: 9179d6d67b9d36263e9568d8e915f13a249fbe8103bce529ecf8ecd86f5eff04
3
+ metadata.gz: e1108e8ad1844399f3606f873dd03b65fb4131a130b829ba1332636ffa7bae74
4
+ data.tar.gz: c736a7bf0cd0e6fc3a6000b288c9b411dc53cf30857b61698bc6b28b82bb7a63
5
5
  SHA512:
6
- metadata.gz: 673ac864ebd2e5e2b008811f10b69f2d2a4fe053dc2aaa72f66ac1057e79e4871e81af729ee59869a5f32b0f968c68e808388a25be666d75e161379d39fa8422
7
- data.tar.gz: 303d55dce5f0780aa227719327ec550f64a710be8e7af978065971f5e03d4a59ffdee5cc91373eb0959f67c817f5cbe301c92c890a9ffafa7f6aaa8223847c99
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
@@ -1,3 +1,3 @@
1
1
  module Clag
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -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.3
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-04 00:00:00.000000000 Z
11
+ date: 2024-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cli-kit