mokkku 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mokkku/cli/runner.rb +5 -1
- data/lib/mokkku/generators/builder.rb +3 -0
- data/lib/mokkku/generators/claude.rb +24 -0
- data/lib/mokkku/version.rb +1 -1
- data/lib/mokkku/yaml_sanitizer.rb +13 -0
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04c69427e72610fa1be06c75060a255eb0ab45c64b3e1a65a5649aa2420552f7
|
4
|
+
data.tar.gz: efc88cd532cd54f28ae0dc4fb2c8cfba8fb0d3e674183494fdc47ef8adcfef15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afc7eb5280d025becdd44e0bd65412645a15bea68812ccc3c09a9179f79b2327faed3937c326c5da56f484a29cafc65e2d1f7bdf98550fff3d8a40995698f864
|
7
|
+
data.tar.gz: e07d24c250a66e1550da05e37a4961c3d4ad0e389e905aa662ca514ac9b96af48c263d3c24fab1e5281884f267381c5fbe588d8c67cd1540981388e81d707e81
|
data/lib/mokkku/cli/runner.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require_relative 'validator'
|
2
2
|
require_relative 'prompt'
|
3
3
|
require_relative '../generators/builder'
|
4
|
+
require_relative '../yaml_sanitizer'
|
4
5
|
|
5
6
|
module Mokkku
|
6
7
|
module Cli
|
@@ -21,7 +22,10 @@ module Mokkku
|
|
21
22
|
mock_file_name = model_name.to_s.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase
|
22
23
|
|
23
24
|
puts "Write mocks for #{model_name} model in #{mock_file_name}.yml"
|
24
|
-
File.write(
|
25
|
+
File.write(
|
26
|
+
File.join(options.fetch(:mocks_path, './spec/mocks'), "#{mock_file_name}.yml"),
|
27
|
+
::Mokkku::YamlSanitizer.sanitize(yaml_mock)
|
28
|
+
)
|
25
29
|
end
|
26
30
|
|
27
31
|
puts 'Done!'
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative 'gpt'
|
2
|
+
require_relative 'claude'
|
2
3
|
|
3
4
|
module Mokkku
|
4
5
|
module Generators
|
@@ -9,6 +10,8 @@ module Mokkku
|
|
9
10
|
case generator
|
10
11
|
when 'gpt'
|
11
12
|
Mokkku::Generators::Gpt
|
13
|
+
when 'claude'
|
14
|
+
Mokkku::Generators::Claude
|
12
15
|
else
|
13
16
|
raise UnsupportedGenerator
|
14
17
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'anthropic'
|
2
|
+
|
3
|
+
module Mokkku
|
4
|
+
module Generators
|
5
|
+
class Claude
|
6
|
+
def self.call(api_key:, prompt:)
|
7
|
+
client = Anthropic::Client.new(access_token: api_key)
|
8
|
+
|
9
|
+
response = client.messages(
|
10
|
+
parameters: {
|
11
|
+
model: 'claude-3-5-sonnet-20240620',
|
12
|
+
system: 'Respond only with code.',
|
13
|
+
messages: [
|
14
|
+
{ 'role': 'user', 'content': prompt },
|
15
|
+
],
|
16
|
+
max_tokens: 1_000
|
17
|
+
}
|
18
|
+
)
|
19
|
+
|
20
|
+
response['content'].first['text']
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/mokkku/version.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
module Mokkku
|
2
|
+
class YamlSanitizer
|
3
|
+
def self.sanitize(yaml_content)
|
4
|
+
# Some LLMs ignore the instructions and return YAML with additions
|
5
|
+
yaml_lines = yaml_content.split("\n")
|
6
|
+
yaml_lines.shift if yaml_lines.first.start_with?("`")
|
7
|
+
yaml_lines.pop if yaml_lines.last.start_with?("`")
|
8
|
+
yaml_lines.shift unless yaml_lines.first.strip.start_with?('-')
|
9
|
+
|
10
|
+
yaml_lines.join("\n")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mokkku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paweł Dąbrowski
|
@@ -58,6 +58,20 @@ dependencies:
|
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: 7.1.0
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: anthropic
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.3.0
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.3.0
|
61
75
|
description: Generate mock data that is unique for your application
|
62
76
|
email: contact@paweldabrowski.com
|
63
77
|
executables:
|
@@ -71,10 +85,12 @@ files:
|
|
71
85
|
- lib/mokkku/cli/runner.rb
|
72
86
|
- lib/mokkku/cli/validator.rb
|
73
87
|
- lib/mokkku/generators/builder.rb
|
88
|
+
- lib/mokkku/generators/claude.rb
|
74
89
|
- lib/mokkku/generators/gpt.rb
|
75
90
|
- lib/mokkku/mocked_object.rb
|
76
91
|
- lib/mokkku/utils.rb
|
77
92
|
- lib/mokkku/version.rb
|
93
|
+
- lib/mokkku/yaml_sanitizer.rb
|
78
94
|
homepage:
|
79
95
|
licenses: []
|
80
96
|
metadata: {}
|