llm.rb 8.1.0 → 10.0.0

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.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +196 -6
  3. data/README.md +233 -518
  4. data/data/anthropic.json +278 -258
  5. data/data/bedrock.json +1288 -1561
  6. data/data/deepseek.json +38 -38
  7. data/data/google.json +656 -579
  8. data/data/openai.json +860 -818
  9. data/data/xai.json +243 -552
  10. data/data/zai.json +168 -168
  11. data/lib/llm/active_record/acts_as_agent.rb +5 -0
  12. data/lib/llm/active_record/acts_as_llm.rb +7 -8
  13. data/lib/llm/active_record.rb +1 -6
  14. data/lib/llm/agent.rb +121 -82
  15. data/lib/llm/context.rb +79 -74
  16. data/lib/llm/contract/completion.rb +45 -0
  17. data/lib/llm/cost.rb +81 -4
  18. data/lib/llm/error.rb +1 -1
  19. data/lib/llm/function/array.rb +8 -5
  20. data/lib/llm/function/call_group.rb +39 -0
  21. data/lib/llm/function/call_task.rb +46 -0
  22. data/lib/llm/function/fork/task.rb +6 -0
  23. data/lib/llm/function/ractor/task.rb +6 -0
  24. data/lib/llm/function/task.rb +10 -0
  25. data/lib/llm/function.rb +28 -1
  26. data/lib/llm/mcp/transport/http.rb +26 -46
  27. data/lib/llm/mcp/transport/stdio.rb +0 -8
  28. data/lib/llm/mcp.rb +6 -23
  29. data/lib/llm/provider.rb +30 -20
  30. data/lib/llm/providers/anthropic/error_handler.rb +6 -7
  31. data/lib/llm/providers/anthropic/files.rb +2 -2
  32. data/lib/llm/providers/anthropic/response_adapter/completion.rb +30 -0
  33. data/lib/llm/providers/anthropic/stream_parser.rb +2 -2
  34. data/lib/llm/providers/anthropic.rb +1 -1
  35. data/lib/llm/providers/bedrock/error_handler.rb +8 -9
  36. data/lib/llm/providers/bedrock/models.rb +13 -13
  37. data/lib/llm/providers/bedrock/response_adapter/completion.rb +30 -0
  38. data/lib/llm/providers/bedrock/stream_parser.rb +2 -2
  39. data/lib/llm/providers/bedrock.rb +1 -1
  40. data/lib/llm/providers/google/error_handler.rb +6 -7
  41. data/lib/llm/providers/google/files.rb +2 -4
  42. data/lib/llm/providers/google/images.rb +1 -1
  43. data/lib/llm/providers/google/models.rb +0 -2
  44. data/lib/llm/providers/google/response_adapter/completion.rb +30 -0
  45. data/lib/llm/providers/google/stream_parser.rb +2 -2
  46. data/lib/llm/providers/google.rb +1 -1
  47. data/lib/llm/providers/ollama/error_handler.rb +6 -7
  48. data/lib/llm/providers/ollama/models.rb +0 -2
  49. data/lib/llm/providers/ollama/response_adapter/completion.rb +30 -0
  50. data/lib/llm/providers/ollama.rb +1 -1
  51. data/lib/llm/providers/openai/audio.rb +3 -3
  52. data/lib/llm/providers/openai/error_handler.rb +6 -7
  53. data/lib/llm/providers/openai/files.rb +2 -2
  54. data/lib/llm/providers/openai/images.rb +3 -3
  55. data/lib/llm/providers/openai/models.rb +1 -1
  56. data/lib/llm/providers/openai/response_adapter/completion.rb +42 -0
  57. data/lib/llm/providers/openai/response_adapter/responds.rb +39 -0
  58. data/lib/llm/providers/openai/responses/stream_parser.rb +2 -2
  59. data/lib/llm/providers/openai/responses.rb +2 -2
  60. data/lib/llm/providers/openai/stream_parser.rb +2 -2
  61. data/lib/llm/providers/openai/vector_stores.rb +1 -1
  62. data/lib/llm/providers/openai.rb +1 -1
  63. data/lib/llm/response.rb +10 -8
  64. data/lib/llm/schema.rb +11 -0
  65. data/lib/llm/sequel/agent.rb +5 -0
  66. data/lib/llm/sequel/plugin.rb +8 -14
  67. data/lib/llm/stream/queue.rb +15 -42
  68. data/lib/llm/stream.rb +15 -40
  69. data/lib/llm/tool/param.rb +1 -8
  70. data/lib/llm/transport/execution.rb +67 -0
  71. data/lib/llm/transport/http.rb +134 -0
  72. data/lib/llm/transport/persistent_http.rb +152 -0
  73. data/lib/llm/transport/response/http.rb +113 -0
  74. data/lib/llm/transport/response.rb +112 -0
  75. data/lib/llm/{provider/transport/http → transport}/stream_decoder.rb +8 -4
  76. data/lib/llm/transport.rb +139 -0
  77. data/lib/llm/usage.rb +14 -5
  78. data/lib/llm/utils.rb +24 -14
  79. data/lib/llm/version.rb +1 -1
  80. data/lib/llm.rb +3 -12
  81. data/llm.gemspec +2 -16
  82. metadata +13 -20
  83. data/lib/llm/bot.rb +0 -3
  84. data/lib/llm/provider/transport/http/execution.rb +0 -115
  85. data/lib/llm/provider/transport/http/interruptible.rb +0 -114
  86. data/lib/llm/provider/transport/http.rb +0 -145
data/data/deepseek.json CHANGED
@@ -28,30 +28,31 @@
28
28
  ]
29
29
  },
30
30
  "open_weights": true,
31
+ "limit": {
32
+ "context": 1000000,
33
+ "output": 384000
34
+ },
31
35
  "cost": {
32
36
  "input": 0.14,
33
37
  "output": 0.28,
34
38
  "cache_read": 0.028
35
- },
36
- "limit": {
37
- "context": 1000000,
38
- "output": 384000
39
39
  }
40
40
  },
41
- "deepseek-reasoner": {
42
- "id": "deepseek-reasoner",
43
- "name": "DeepSeek Reasoner",
41
+ "deepseek-v4-pro": {
42
+ "id": "deepseek-v4-pro",
43
+ "name": "DeepSeek V4 Pro",
44
44
  "family": "deepseek-thinking",
45
- "attachment": true,
45
+ "attachment": false,
46
46
  "reasoning": true,
47
47
  "tool_call": true,
48
48
  "interleaved": {
49
49
  "field": "reasoning_content"
50
50
  },
51
+ "structured_output": true,
51
52
  "temperature": true,
52
- "knowledge": "2025-09",
53
- "release_date": "2025-12-01",
54
- "last_updated": "2026-02-28",
53
+ "knowledge": "2025-05",
54
+ "release_date": "2026-04-24",
55
+ "last_updated": "2026-04-24",
55
56
  "modalities": {
56
57
  "input": [
57
58
  "text"
@@ -61,31 +62,30 @@
61
62
  ]
62
63
  },
63
64
  "open_weights": true,
64
- "cost": {
65
- "input": 0.14,
66
- "output": 0.28,
67
- "cache_read": 0.028
68
- },
69
65
  "limit": {
70
66
  "context": 1000000,
71
67
  "output": 384000
68
+ },
69
+ "cost": {
70
+ "input": 1.74,
71
+ "output": 3.48,
72
+ "cache_read": 0.145
72
73
  }
73
74
  },
74
- "deepseek-v4-flash": {
75
- "id": "deepseek-v4-flash",
76
- "name": "DeepSeek V4 Flash",
77
- "family": "deepseek-flash",
78
- "attachment": false,
75
+ "deepseek-reasoner": {
76
+ "id": "deepseek-reasoner",
77
+ "name": "DeepSeek Reasoner",
78
+ "family": "deepseek-thinking",
79
+ "attachment": true,
79
80
  "reasoning": true,
80
81
  "tool_call": true,
81
82
  "interleaved": {
82
83
  "field": "reasoning_content"
83
84
  },
84
- "structured_output": true,
85
85
  "temperature": true,
86
- "knowledge": "2025-05",
87
- "release_date": "2026-04-24",
88
- "last_updated": "2026-04-24",
86
+ "knowledge": "2025-09",
87
+ "release_date": "2025-12-01",
88
+ "last_updated": "2026-02-28",
89
89
  "modalities": {
90
90
  "input": [
91
91
  "text"
@@ -95,20 +95,20 @@
95
95
  ]
96
96
  },
97
97
  "open_weights": true,
98
+ "limit": {
99
+ "context": 1000000,
100
+ "output": 384000
101
+ },
98
102
  "cost": {
99
103
  "input": 0.14,
100
104
  "output": 0.28,
101
105
  "cache_read": 0.028
102
- },
103
- "limit": {
104
- "context": 1000000,
105
- "output": 384000
106
106
  }
107
107
  },
108
- "deepseek-v4-pro": {
109
- "id": "deepseek-v4-pro",
110
- "name": "DeepSeek V4 Pro",
111
- "family": "deepseek-thinking",
108
+ "deepseek-v4-flash": {
109
+ "id": "deepseek-v4-flash",
110
+ "name": "DeepSeek V4 Flash",
111
+ "family": "deepseek-flash",
112
112
  "attachment": false,
113
113
  "reasoning": true,
114
114
  "tool_call": true,
@@ -129,14 +129,14 @@
129
129
  ]
130
130
  },
131
131
  "open_weights": true,
132
- "cost": {
133
- "input": 1.74,
134
- "output": 3.48,
135
- "cache_read": 0.145
136
- },
137
132
  "limit": {
138
133
  "context": 1000000,
139
134
  "output": 384000
135
+ },
136
+ "cost": {
137
+ "input": 0.14,
138
+ "output": 0.28,
139
+ "cache_read": 0.028
140
140
  }
141
141
  }
142
142
  }