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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 234a86d569711e52239d937a81d56f24f2b15df2fc70d3bdc534cb95775e1d7b
4
- data.tar.gz: 2f25efb4d4351948b99991f698621cb9a44ba512146ecf2834bb60cf2c9db818
3
+ metadata.gz: 04c69427e72610fa1be06c75060a255eb0ab45c64b3e1a65a5649aa2420552f7
4
+ data.tar.gz: efc88cd532cd54f28ae0dc4fb2c8cfba8fb0d3e674183494fdc47ef8adcfef15
5
5
  SHA512:
6
- metadata.gz: b4f7e2e15f31417967cd38fa3141197e8515b9e58fe867a79a5a8e0fbe826579002afb16676dfdaba0aa3fca8d3d75dac162ba516b14036b4d12c87800d0ebad
7
- data.tar.gz: 9bf25b64bcc41d563c8b5f64f395b6d2325f42fb2599b5c2d16c6ed5810544f7ea461646e61b12d7b02b22436216680a1b50310b8a65dae25be37b6096447a4f
6
+ metadata.gz: afc7eb5280d025becdd44e0bd65412645a15bea68812ccc3c09a9179f79b2327faed3937c326c5da56f484a29cafc65e2d1f7bdf98550fff3d8a40995698f864
7
+ data.tar.gz: e07d24c250a66e1550da05e37a4961c3d4ad0e389e905aa662ca514ac9b96af48c263d3c24fab1e5281884f267381c5fbe588d8c67cd1540981388e81d707e81
@@ -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(File.join(options.fetch(:mocks_path, './spec/mocks'), "#{mock_file_name}.yml"), yaml_mock)
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
@@ -3,7 +3,7 @@ module Mokkku
3
3
  module_function
4
4
 
5
5
  def to_s
6
- '0.0.2'
6
+ '0.0.3'
7
7
  end
8
8
  end
9
9
  end
@@ -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.2
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: {}