llmed 0.3.10 → 0.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 16b00d93a0c1d26a43250c2c781cafe0cf5e6b9519f3716af8796bf6ca8b6ccd
4
- data.tar.gz: c26d287cc392a00e9a71dc8182dcbd05e3ab29a234414adba04b95a11668860f
3
+ metadata.gz: 0cd0f86146f0b5d3123e0bffdd50f66017b5961c94f3e589236a579157a8db3e
4
+ data.tar.gz: 82f083351481d1e14e5cdcf1640027dd032f242c7390e0421f075e1214a2bd95
5
5
  SHA512:
6
- metadata.gz: f5a930b1bb6045877cb4bb8cc43e4729aa89a0b127beeeebd05ee8dd70c189562cf6aef32e53be2b6b5114169acc29d8392c7e180ac67885504c24b706657cdc
7
- data.tar.gz: be35fa33dcbee7b9cb037aebd811dfb1ee2768f7b24b2847c8b1ba3963436037e32ad41cdda5ca15278c2a470553412a41934e5e5c3f3083a384e3fe03f11bd4
6
+ metadata.gz: 825b0583fe3f59190eef5dd2cd618d38e5b244409d91ca7ce5fe1baef60f19cb9a6acb967aa3b260439fec0d321da552a65b4fc280fb10d537a138eca6315791
7
+ data.tar.gz: 44744f6d6c0b24ea109e191461aae86e6a9fa63347e7a90143f41672986befb82809c274441514efcc79323c714abeb5bb154b5f6a274fdb6a6b86d439f6650c
data/lib/llm.rb CHANGED
@@ -19,6 +19,9 @@ class LLMed
19
19
  Response = Struct.new(:provider, :model, :source_code, :duration_seconds, :total_tokens, keyword_init: true)
20
20
 
21
21
  class OpenAI
22
+
23
+ DEFAULT_URI_BASE = "https://api.openai.com/".freeze
24
+
22
25
  def initialize(**args)
23
26
  @llm = Langchain::LLM::OpenAI.new(**llm_arguments(args))
24
27
  end
@@ -45,10 +48,6 @@ class LLMed
45
48
 
46
49
  private
47
50
 
48
- def llm_arguments(args)
49
- args
50
- end
51
-
52
51
  def provider
53
52
  :openai
54
53
  end
@@ -70,6 +69,18 @@ class LLMed
70
69
  end
71
70
  end
72
71
 
72
+ class LikeOpenAI < OpenAI
73
+ private
74
+
75
+ def llm_arguments(args)
76
+ args
77
+ end
78
+
79
+ def provider
80
+ :like_openai
81
+ end
82
+ end
83
+
73
84
  class Test
74
85
  def initialize
75
86
  @output = ''
@@ -120,6 +120,8 @@ class LLMed
120
120
  def system_prompt(configuration)
121
121
  configuration.prompt(language: language,
122
122
  source_code: source_code,
123
+ code_comment_begin: @code_comment.begin,
124
+ code_comment_end: @code_comment.end,
123
125
  update_context_digests: digests_of_context_to_update)
124
126
  end
125
127
 
@@ -9,7 +9,6 @@ class LLMed
9
9
  You are a software developer with knowledge only of the programming language {language}, following the SOLID principles strictly, you always use only imperative and functional programming, design highly isolated components.
10
10
  The contexts are declarations of how the source code will be (not a file) ensure to follow this always.
11
11
  The contexts are connected as a flat linked list.
12
- Your response must contain only the generated source code, with no additional text or comments, and ou must ensure that runs correctly on the first attempt.
13
12
  All the contexts represent one source code.
14
13
  There is always a one-to-one correspondence between context and source code.
15
14
  Always include the properly escaped comment: LLMED-COMPILED.
@@ -19,22 +18,27 @@ You must only modify the following source code:
19
18
 
20
19
  Only generate source code of the context who digest belongs to {update_context_digests} or a is a new context.
21
20
 
22
- Wrap with comment every code that belongs to the indicated context, example in ruby:
23
- #<llmed-code context='context name' digest='....' after='digest next context'>
21
+ Wrap with comment every code that belongs to the indicated context, example in {language}:
22
+ {code_comment_begin}<llmed-code context='context name' digest='....' after='digest next context'>{code_comment_end}
24
23
  ...
25
- #</llmed-code>
26
- ", input_variables: %w[language source_code update_context_digests])
24
+ {code_comment_begin}</llmed-code>{code_comment_end}
25
+
26
+ !!Your response must contain only the generated source code, with no additional text or comments, and you must ensure that runs correctly on the first attempt.
27
+ ", input_variables: %w[language source_code code_comment_begin code_comment_end update_context_digests])
27
28
  end
28
29
 
29
- def prompt(language:, source_code:, update_context_digests: [])
30
- @prompt.format(language: language, source_code: source_code,
30
+ def prompt(language:, source_code:, code_comment_begin:, code_comment_end:, update_context_digests: [])
31
+ @prompt.format(language: language,
32
+ source_code: source_code,
33
+ code_comment_begin: code_comment_begin,
34
+ code_comment_end: code_comment_end,
31
35
  update_context_digests: update_context_digests.join(','))
32
36
  end
33
37
 
34
38
  # Change the default prompt, input variables: language, source_code
35
39
  # Example:
36
40
  # set_prompt "my new prompt"
37
- def set_prompt(*arg, input_variables: %w[language source_code], **args)
41
+ def set_prompt(*arg, input_variables: %w[language code_comment_begin code_comment_end source_code], **args)
38
42
  input_variables = {} if args[:file]
39
43
  prompt = File.read(args[:file]) if args[:file]
40
44
  prompt ||= arg.first
@@ -48,10 +52,11 @@ Wrap with comment every code that belongs to the indicated context, example in r
48
52
  @language = language
49
53
  end
50
54
 
51
- def set_llm(provider:, api_key:, model:)
55
+ def set_llm(provider:, api_key:, model:, options: {})
52
56
  @provider = provider
53
57
  @provider_api_key = api_key
54
58
  @provider_model = model
59
+ @provider_options = options
55
60
  end
56
61
 
57
62
  def language(main)
@@ -73,6 +78,12 @@ Wrap with comment every code that belongs to the indicated context, example in r
73
78
  api_key: @provider_api_key,
74
79
  default_options: { temperature: 0.7, chat_model: @provider_model }
75
80
  )
81
+ when :like_openai
82
+ LLMed::LLM::LikeOpenAI.new(
83
+ api_key: @provider_api_key,
84
+ default_options: { temperature: 0.7, chat_model: @provider_model },
85
+ llm_options: @provider_options
86
+ )
76
87
  when :test
77
88
  LLMed::LLM::Test.new
78
89
  when nil
@@ -0,0 +1,18 @@
1
+ # Copyright 2025 Jovany Leandro G.C <bit4bit@riseup.net>
2
+ # frozen_string_literal: true
3
+
4
+ class LLMed
5
+ class Deployment
6
+ def initialize(name:, output_dir:, logger:, block:)
7
+ @name = name
8
+ @output_dir = output_dir
9
+ @logger = logger
10
+ @block = block
11
+ end
12
+
13
+ def execute
14
+ @logger.info("DEPLOYMENT [#{@name}] EXECUTING")
15
+ instance_eval(&@block)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ # Copyright 2025 Jovany Leandro G.C <bit4bit@riseup.net>
2
+ # frozen_string_literal: true
3
+
4
+ class LLMed
5
+ class Deployment
6
+ def initialize(name:, output_dir:, block:)
7
+ @name = name
8
+ @output_dir = output_dir
9
+ @block = block
10
+ end
11
+
12
+ def execute()
13
+ self.instance_eval(@block)
14
+ end
15
+ end
16
+ end
data/lib/llmed/release.rb CHANGED
@@ -125,7 +125,7 @@ class LLMed
125
125
  @code_comment = code_comment
126
126
  @contexts = []
127
127
 
128
- @origin.scan(%r{<llmed-code context='(.+?)' digest='(.+?)'\s*(after='.*?')?>#{@code_comment.end}(.+?)#{@code_comment.begin}+\s*</llmed-code}im).each do |match|
128
+ @origin.scan(%r{<llmed-code context='(.+?)' digest='(.+?)'\s*(after='.*?')?>#{@code_comment.end}(.+?)#{@code_comment.begin}+\s*<?/?llmed-code}im).each do |match|
129
129
  name, digest, after_block, code = match
130
130
  after = if after_block.nil?
131
131
  ''
data/lib/llmed.rb CHANGED
@@ -16,6 +16,7 @@ class LLMed
16
16
  def initialize(logger:, output_dir:, release_dir:)
17
17
  @logger = logger
18
18
  @applications = []
19
+ @deploys = []
19
20
  @configuration = Configuration.new
20
21
  @release_dir = release_dir || output_dir
21
22
  @output_dir = output_dir
@@ -46,10 +47,18 @@ class LLMed
46
47
  @applications << @app
47
48
  end
48
49
 
50
+ def deploy(name, &block)
51
+ @deploys << Deployment.new(name: name, output_dir: @output_dir, logger: @logger, block: block)
52
+ end
53
+
49
54
  def compile
50
55
  @applications.each do |app|
51
56
  compile_application(app)
52
57
  end
58
+
59
+ @deploys.each do |deploy|
60
+ deploy.execute
61
+ end
53
62
  end
54
63
 
55
64
  private
@@ -84,3 +93,4 @@ require_relative 'llmed/configuration'
84
93
  require_relative 'llmed/context'
85
94
  require_relative 'llmed/release'
86
95
  require_relative 'llmed/application'
96
+ require_relative 'llmed/deployment'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llmed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.10
4
+ version: 0.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jovany Leandro G.C
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-06-11 00:00:00.000000000 Z
11
+ date: 2025-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: langchainrb
@@ -102,6 +102,8 @@ files:
102
102
  - lib/llmed/configuration.rb~
103
103
  - lib/llmed/context.rb
104
104
  - lib/llmed/context.rb~
105
+ - lib/llmed/deployment.rb
106
+ - lib/llmed/deployment.rb~
105
107
  - lib/llmed/release.rb
106
108
  - lib/llmed/release.rb~
107
109
  homepage: https://github.com/bit4bit/llmed