llmed 0.3.16 → 0.3.18

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: 3d5362d8a48de51f33d6cc43bdd166387d7d36f0242cca147c126da4678721fc
4
- data.tar.gz: 25d0960a155f4c8abb600eae9853b28215808635a4d0da812f381db31bf74a1a
3
+ metadata.gz: a2d293c8ee975eb321825f0e913ae677ac82a637e17eb5ec937f2cc787e60f00
4
+ data.tar.gz: c452a909758522e6a9a802f04fd65d20bb1e0afbc126045a7ddd54e2254109d5
5
5
  SHA512:
6
- metadata.gz: d9fbca340377b6b8370426839faa236ce23b803870651d00da2d2c719ded31cbd4d5a9929fd8855fd486bb79f60780f13acc3f82b228e29d4df5ebdd8fcf9d5c
7
- data.tar.gz: 697c10a3fd025fc31cb3e8ef0f33765eb686ebf6fb174f33bbc79a51eed1020615489a33cd0557b97b058ab10badc446c3e74665deb6ccc448ffabbd4dddaa96
6
+ metadata.gz: 27c0f743139d321d6eef06fc26a7bc9c0ba2a6a0cbae25e0796d17f2b2f6b01871972ba4dd1be856e86663bf1f4de4dae8a426bc01184a7296f38c090ee6b4a7
7
+ data.tar.gz: 30044ce1bc97933d40b739309805983243129fbb2985a7bdfb14e57a5e2ccd0e3b18495ed9d635a97e9c25c040d7000a444f2dce3b2fadcace7cd5d4b97698b6
@@ -0,0 +1,36 @@
1
+ set_llm provider: :openai, api_key: ENV['OPENAI_API_KEY'], model: 'gpt-4o-mini'
2
+ #set_llm provider: :like_openai, api_key: ENV['TOGETHERAI_API_KEY'], model: 'Qwen/Qwen2.5-Coder-32B-Instruct', options: {uri_base: 'https://api.together.xyz/v1'}
3
+
4
+ application "Literate Programming Markdown", release: nil, language: :ruby, output_file: "markdown.rb", output_dir: "literate_programming" do
5
+ context "Library LLmed::LiterateProgramming::Markdown" do
6
+ <<-LLM
7
+ Exports the function `parse(input: String)`.
8
+ Example of expected behavior:
9
+ ```ruby
10
+ md = LLmed::LiteratePrograming::Markdown.new()
11
+ md.parse("
12
+ # Context A
13
+ Contenido
14
+ [link](http://link)
15
+ ## SubContexto A
16
+ SubContenido
17
+
18
+ # Contexto 3
19
+ Contenido 3
20
+
21
+ ") == [{type: :context,
22
+ title: "Context A",
23
+ content: [
24
+ {type: :string, content: "Contenido\n"},
25
+ {type: :link, content: "link", reference: "http://link"},
26
+ {type: :string, content: "##SubContexto A\nSubContenido\n\n"}
27
+ ]},
28
+ {type: :context,
29
+ title: "Contexto 3",
30
+ content: [
31
+ {type: :string, content: "Contenido 3\n\n"}
32
+ ]}]
33
+ ```
34
+ LLM
35
+ end
36
+ end
@@ -0,0 +1,39 @@
1
+ set_llm provider: :like_openai, api_key: ENV['TOGETHERAI_API_KEY'], model: 'Qwen/Qwen2.5-Coder-32B-Instruct', options: {uri_base: 'https://api.together.xyz/v1'}
2
+
3
+ application "Literate Programming Markdown", release: nil, language: :ruby, output_file: "markdown.rb", output_dir: "literate_programming" do
4
+ context "Library LLmed::LiterateProgramming::Markdown" do
5
+ <<-LLM
6
+ Exports a function call `parse(input: String)`.
7
+
8
+ ### Example of usage
9
+
10
+ ```ruby
11
+ md = LLmed::LiteratePrograming::Markdown.new()
12
+ md.parse("
13
+ # Context A
14
+ Contenido
15
+ [link](http://link)
16
+ ## SubContexto A
17
+ SubContenido
18
+
19
+ # Contexto 3
20
+ Contenido 3
21
+
22
+ ") == [{type: :context,
23
+ title: "Context A",
24
+ content: [
25
+ {type: :string, content: "Contenido\n"},
26
+ {type: :link, content: "link", reference: "http://link"},
27
+ {type: :string, content: "##SubContexto A\nSubContenido\n\n"}
28
+ ]},
29
+ {type: :context,
30
+ title: "Contexto 3",
31
+ content: [
32
+ {type: :string, content: "Contenido 3\n\n"}
33
+ ]}]
34
+ ```
35
+
36
+
37
+ LLM
38
+ end
39
+ end
@@ -102,6 +102,7 @@ class LLMed
102
102
  output_release = Release.load(File.read(release_source_code), @code_comment)
103
103
  input_release = Release.load(output, @code_comment)
104
104
  output_content = output_release.merge!(input_release, user_contexts).content
105
+
105
106
  output_release.changes.each do |change|
106
107
  action, ctx = change
107
108
  case action
@@ -15,9 +15,11 @@ There is always a one-to-one correspondence between context and source code.
15
15
  Always include the properly escaped comment: LLMED-COMPILED.
16
16
 
17
17
  You must only modify the following source code:
18
+ ```
18
19
  {source_code}
20
+ ```
19
21
 
20
- Only generate source code of the context who digest belongs to {update_context_digests} or a is a new context.
22
+ Only generate source code of the context who digest belongs to {update_context_digests}.
21
23
 
22
24
  Wrap with comment every code that belongs to the indicated context, example in {language}:
23
25
  {code_comment_begin}<llmed-code context='context name' digest='....' after='digest next context'>{code_comment_end}
@@ -0,0 +1,35 @@
1
+ set_llm provider: :like_openai, api_key: ENV['TOGETHERAI_API_KEY'], model: 'Qwen/Qwen2.5-Coder-32B-Instruct', options: {uri_base: 'https://api.together.xyz/v1'}
2
+
3
+ application "Literate Programming Markdown", release: nil, language: :ruby, output_file: "markdown.rb", output_dir: "literate_programming" do
4
+ context "Library LLmed::LiterateProgramming::Markdown" do
5
+ <<-LLM
6
+ Exports the function `parse(input: String)`.
7
+ Example of expected behavior:
8
+ ```ruby
9
+ md = LLmed::LiteratePrograming::Markdown.new()
10
+ md.parse("
11
+ # Context A
12
+ Contenido
13
+ [link](http://link)
14
+ ## SubContexto A
15
+ SubContenido
16
+
17
+ # Contexto 3
18
+ Contenido 3
19
+
20
+ ") == [{type: :context,
21
+ title: "Context A",
22
+ content: [
23
+ {type: :string, content: "Contenido\n"},
24
+ {type: :link, content: "link", reference: "http://link"},
25
+ {type: :string, content: "##SubContexto A\nSubContenido\n\n"}
26
+ ]},
27
+ {type: :context,
28
+ title: "Contexto 3",
29
+ content: [
30
+ {type: :string, content: "Contenido 3\n\n"}
31
+ ]}]
32
+ ```
33
+ LLM
34
+ end
35
+ end
@@ -0,0 +1 @@
1
+ {"inserted_at":1750948249,"name":"Literate Programming Markdown","provider":"like_openai","model":"Qwen/Qwen2.5-Coder-32B-Instruct","release":null,"total_tokens":825,"duration_seconds":6}
data/lib/llmed/release.rb CHANGED
@@ -106,13 +106,30 @@ class LLMed
106
106
  # insertions missed user contexts
107
107
  user_contexts.each do |name, digest|
108
108
  next if contexts.any? { |ctx| ctx.name == name }
109
-
110
- new_ctx = ContextCode.new(name, digest, "\n", '')
109
+ code = release.context_by(name).code
110
+ new_ctx = ContextCode.new(name, digest, code, '')
111
111
  contexts.prepend(new_ctx)
112
112
  @changes << [:added, new_ctx]
113
113
  end
114
114
 
115
- @contexts = contexts
115
+ contexts_sorted = []
116
+ # prioritize user order
117
+ user_contexts.each do |name, _digest|
118
+ contexts.each do |ctx|
119
+ if ctx.name == name
120
+ contexts_sorted << ctx
121
+ break
122
+ end
123
+ end
124
+ end
125
+
126
+ @contexts = contexts_sorted.sort {|a,b|
127
+ if a.digest == b.after
128
+ 1
129
+ else
130
+ 0
131
+ end
132
+ }
116
133
  self
117
134
  end
118
135
 
data/lib/llmed.rb CHANGED
@@ -33,7 +33,7 @@ class LLMed
33
33
  # changes default prompt
34
34
  def_delegator :@configuration, :set_prompt, :set_prompt
35
35
 
36
- def application(name, output_file:, language: nil, release: nil, &block)
36
+ def application(name, output_file:, language: nil, release: nil, output_dir: nil, &block)
37
37
  @app = Application.new(
38
38
  name: name,
39
39
  language: @configuration.language(language),
@@ -42,7 +42,7 @@ class LLMed
42
42
  logger: @logger,
43
43
  release: release,
44
44
  release_dir: @release_dir,
45
- output_dir: @output_dir
45
+ output_dir: output_dir || @output_dir
46
46
  )
47
47
  @applications << @app
48
48
  end
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.16
4
+ version: 0.3.18
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-24 00:00:00.000000000 Z
11
+ date: 2025-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: langchainrb
@@ -92,6 +92,8 @@ files:
92
92
  - LICENSE
93
93
  - README.md
94
94
  - exe/llmed
95
+ - lib/literate_programming.llmed
96
+ - lib/literate_programming.llmed~
95
97
  - lib/llm.rb
96
98
  - lib/llm.rb~
97
99
  - lib/llmed.rb
@@ -104,8 +106,9 @@ files:
104
106
  - lib/llmed/context.rb~
105
107
  - lib/llmed/deployment.rb
106
108
  - lib/llmed/deployment.rb~
107
- - lib/llmed/literate_programming.rb
109
+ - lib/llmed/literate_programming.llmed
108
110
  - lib/llmed/literate_programming.rb~
111
+ - lib/llmed/markdown.rb.statistics
109
112
  - lib/llmed/release.rb
110
113
  - lib/llmed/release.rb~
111
114
  homepage: https://github.com/bit4bit/llmed
@@ -1,50 +0,0 @@
1
- require 'toml-rb'
2
-
3
- class LLMed
4
- class LiterateProgramming
5
- ContentString = Struct.new(:content, keyword_init: true) do
6
- def to_s
7
- content
8
- end
9
- end
10
- ContentFencedBlock = Struct.new(:format, :arguments, :content, keyword_init: true)
11
- Context = Struct.new(:name, :content, :content_desc, keyword_init: true)
12
- Application = Struct.new(:configuration, :contexts, keyword_init: true)
13
-
14
- class Markdown
15
-
16
- def parse(content)
17
- content.scan(/^---(.+?)---\n(.+)/m) => [[configuration_data, application_data]]
18
-
19
- app = Application.new(configuration: TomlRB.parse(configuration_data), contexts: [])
20
-
21
- application_data.split(/^# /)
22
- .reject{|c| c.empty?}
23
- .each do |context_data|
24
- case context_data.split("\n", 2)
25
- in ["", ""]
26
- # omit
27
- in [name, content]
28
- context_desc = []
29
- content.split(/(```.*```)/mi).each do |line|
30
- if line.start_with?("```")
31
- line.scan(/```(.+?)\n(.+)```/mi) => [[fenced_data, fenced_content]]
32
- fenced_params = fenced_data.split(",")
33
- format = fenced_params.shift
34
- arguments = fenced_params.map{|item| item.split("=", 2)}.to_h
35
-
36
- context_desc << ContentFencedBlock.new(format: format, arguments: arguments, content: fenced_content)
37
- else
38
- context_desc << ContentString.new(content: line)
39
- end
40
- end
41
-
42
- app.contexts << Context.new(name: name, content: content, content_desc: context_desc)
43
- end
44
- end
45
-
46
- app
47
- end
48
- end
49
- end
50
- end