slidict 0.4.0 → 0.4.1
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 +4 -4
- data/.github/release-drafter.yml +1 -1
- data/lib/slidict/cli/lint.rb +3 -1
- data/lib/slidict/lint/linter.rb +2 -2
- data/lib/slidict/llm/client.rb +5 -4
- data/lib/slidict/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 72ffe395b54c50043126018602fe50cde4e7e9ffdc666dd4c403b76b0fc97753
|
|
4
|
+
data.tar.gz: 1f8fd030ddb53433a334af861bcb1bf4fdb2a191de50657d900a74936e4ca767
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b33d3e8fde16b58ace800bc590edd63cd67bdb20f595dff60367182c440b8f57fa779632a8da4f72a885061bd400a576b888f4c555684fd2e2c615e14fb589f6
|
|
7
|
+
data.tar.gz: 61cc90648bd97afd6dbda04aed0406f7f7601553852319f05a05905187752057d951805f03facac2003efebadbf97625092e814b952ec347c08000130c3ddf37
|
data/.github/release-drafter.yml
CHANGED
data/lib/slidict/cli/lint.rb
CHANGED
|
@@ -36,7 +36,7 @@ module Slidict
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def lint(options, config)
|
|
39
|
-
@linter_factory.call(config).lint(File.read(options[:path]), format: format_for(options))
|
|
39
|
+
@linter_factory.call(config).lint(File.read(options[:path]), format: format_for(options), translate: options[:translate])
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def print_usage_error(error)
|
|
@@ -70,6 +70,7 @@ module Slidict
|
|
|
70
70
|
when "--llm-base-url" then options[:llm_base_url] = fetch_value!(args, arg)
|
|
71
71
|
when "--llm-api-key" then options[:llm_api_key] = fetch_value!(args, arg)
|
|
72
72
|
when "--llm-model" then options[:llm_model] = fetch_value!(args, arg)
|
|
73
|
+
when "--translate" then options[:translate] = fetch_value!(args, arg)
|
|
73
74
|
else raise ArgumentError, "unknown option #{arg}"
|
|
74
75
|
end
|
|
75
76
|
end
|
|
@@ -124,6 +125,7 @@ module Slidict
|
|
|
124
125
|
--llm-base-url URL OpenAI Compatible API base URL (env: SLIDICT_LLM_BASE_URL)
|
|
125
126
|
--llm-api-key KEY API key for the LLM endpoint (env: SLIDICT_LLM_API_KEY)
|
|
126
127
|
--llm-model NAME Model name to request (env: SLIDICT_LLM_MODEL, default: gpt-4o-mini)
|
|
128
|
+
--translate LANG Translate findings into the given language (e.g. Japanese)
|
|
127
129
|
-h, --help Show this help
|
|
128
130
|
HELP
|
|
129
131
|
0
|
data/lib/slidict/lint/linter.rb
CHANGED
|
@@ -11,11 +11,11 @@ module Slidict
|
|
|
11
11
|
@client = client
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
def lint(content, format: "markdown")
|
|
14
|
+
def lint(content, format: "markdown", translate: nil)
|
|
15
15
|
slides = SlideParser.parse(content, format: format)
|
|
16
16
|
raise Error, "no slides found in the given file" if slides.empty?
|
|
17
17
|
|
|
18
|
-
@client.lint_slides(slides)
|
|
18
|
+
@client.lint_slides(slides, translate: translate)
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
end
|
data/lib/slidict/llm/client.rb
CHANGED
|
@@ -37,8 +37,8 @@ module Slidict
|
|
|
37
37
|
# slide_texts is an array of slide bodies (1-indexed by position) as
|
|
38
38
|
# produced by Slidict::Lint::SlideParser. Returns an array of
|
|
39
39
|
# Slidict::Lint::Finding.
|
|
40
|
-
def lint_slides(slide_texts)
|
|
41
|
-
content = chat_completion(lint_prompt_for(slide_texts))
|
|
40
|
+
def lint_slides(slide_texts, translate: nil)
|
|
41
|
+
content = chat_completion(lint_prompt_for(slide_texts, translate: translate))
|
|
42
42
|
findings_from(content)
|
|
43
43
|
end
|
|
44
44
|
|
|
@@ -93,9 +93,10 @@ module Slidict
|
|
|
93
93
|
JSON array. Return an empty array [] if you find no issues.
|
|
94
94
|
PROMPT
|
|
95
95
|
|
|
96
|
-
def lint_prompt_for(slide_texts)
|
|
96
|
+
def lint_prompt_for(slide_texts, translate: nil)
|
|
97
97
|
numbered = slide_texts.each_with_index.map { |text, i| "--- Slide #{i + 1} ---\n#{text}" }.join("\n\n")
|
|
98
|
-
format(LINT_PROMPT_TEMPLATE, numbered: numbered)
|
|
98
|
+
prompt = format(LINT_PROMPT_TEMPLATE, numbered: numbered)
|
|
99
|
+
translate ? "#{prompt}\nWrite each message field in #{translate}." : prompt
|
|
99
100
|
end
|
|
100
101
|
|
|
101
102
|
def findings_from(content)
|
data/lib/slidict/version.rb
CHANGED