llmed 0.2.6 → 0.2.9

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: 8a6527a6c42fc6c08cecb678864d9cbe7ad98d0a66abc17743b93822f1bb8879
4
- data.tar.gz: d11849c68ef1610aa5ac9bb16a7e91c4dcfa2d6db2b3d6ae60322527f26ca972
3
+ metadata.gz: e56269a5d76f8d9b16ed8df3781111195eb0ca47f591c594440335a45e8f50f9
4
+ data.tar.gz: a094082f5e577cc92b3331ae108795b6c55604375ec9ef393991e32c6efc182d
5
5
  SHA512:
6
- metadata.gz: fdf936634dbae01bf6d1696554eb124847515c8a78f6885f0627375117f323e0da708923670bba8c16710c0b10402202ba48d0fc6c2f82bd7efb0a45d58fd42f
7
- data.tar.gz: 16b15a87b23b1df16bc220f481c2cb3d8456dbf18c8aa43fa9211db681f49b18bc73fe988477cce9ac35b94c44c581461084d22d796b0f9f8e577f9655c01244
6
+ metadata.gz: bbc2eb0c14a528db3782e31069c0163a47483c1e443d802e3c915a4db1544a43d658b00d2a60b0df3b96c806161c3a05dfe942daef06a0146841790347a1dc30
7
+ data.tar.gz: 38e432d45c95e24d221d7bd4486522eee8f336e57a0d3825a776540f78f930aa5ca4db6a0c9c3cb1ece3d93b9901664431ae9cbd13ffdc25afc4792951ddfb71
data/lib/llm.rb CHANGED
@@ -20,7 +20,7 @@ class LLMed
20
20
 
21
21
  class OpenAI
22
22
  def initialize(**args)
23
- @llm = Langchain::LLM::OpenAI.new(**args)
23
+ @llm = Langchain::LLM::OpenAI.new(**llm_arguments(args))
24
24
  end
25
25
 
26
26
  def chat(messages: [])
@@ -36,7 +36,7 @@ class LLMed
36
36
  start = Time.now
37
37
  llm_response = @llm.chat(messages: messages)
38
38
  stop = Time.now
39
- Response.new({ provider: :openai,
39
+ Response.new({ provider: provider,
40
40
  model: @llm.chat_parameters[:model],
41
41
  duration_seconds: stop.to_i - start.to_i,
42
42
  source_code: source_code(llm_response.chat_completion),
@@ -45,8 +45,28 @@ class LLMed
45
45
 
46
46
  private
47
47
 
48
+ def llm_arguments(args)
49
+ args
50
+ end
51
+
52
+ def provider
53
+ :openai
54
+ end
55
+
48
56
  def source_code(content)
49
- content.gsub('```', '').sub(/^(node(js)?|javascript|ruby|python(\d*)|elixir|perl|bash|html|c(pp)?)/, '')
57
+ content.gsub('```', '').sub(/^(node(js)?|javascript|ruby|python(\d*)|elixir|perl|bash|html|c(pp)?)([ \n])/, '')
58
+ end
59
+ end
60
+
61
+ class Anthropic < OpenAI
62
+ private
63
+
64
+ def llm_arguments(args)
65
+ args.merge({ llm_options: { uri_base: 'https://api.anthropic.com/v1/' } })
66
+ end
67
+
68
+ def provider
69
+ :anthropic
50
70
  end
51
71
  end
52
72
 
@@ -8,6 +8,7 @@ class LLMed
8
8
  You are a software developer with knowledge only of the programming language {language}. Follow the SOLID principles strictly, you must use only imperative and functional programming, and design highly isolated components.
9
9
  Your response must contain only the generated source code, with no additional text.
10
10
  All source code must be written in a single file, and you must ensure it runs correctly on the first attempt.
11
+ There is always a one-to-one correspondence between context and source code.
11
12
  Always include the properly escaped comment: LLMED-COMPILED.
12
13
 
13
14
  You must only modify the following source code:
@@ -65,6 +66,11 @@ Wrap with comment every code that belongs to the indicated context, example in r
65
66
  api_key: @provider_api_key,
66
67
  default_options: { temperature: 0.7, chat_model: @provider_model }
67
68
  )
69
+ when :anthropic
70
+ LLMed::LLM::Anthropic.new(
71
+ api_key: @provider_api_key,
72
+ default_options: { temperature: 0.7, chat_model: @provider_model }
73
+ )
68
74
  when :test
69
75
  LLMed::LLM::Test.new
70
76
  when nil
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.2.6
4
+ version: 0.2.9
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-07 00:00:00.000000000 Z
11
+ date: 2025-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: langchainrb