llm.rb 16.0.0 → 17.0.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.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +535 -2
  3. data/README.md +857 -501
  4. data/data/alibaba.json +2 -2
  5. data/data/anthropic.json +66 -3
  6. data/data/bedrock.json +781 -12
  7. data/data/deepinfra.json +157 -1
  8. data/data/google.json +48 -0
  9. data/data/mistral.json +326 -16
  10. data/data/moonshot.json +2 -1
  11. data/data/openai.json +13 -0
  12. data/data/openrouter.json +1078 -1235
  13. data/data/xai.json +4 -2
  14. data/docs/deepdive/advanced/cancellation.md +35 -7
  15. data/docs/deepdive/advanced/compaction.md +5 -5
  16. data/docs/deepdive/advanced/context.md +45 -24
  17. data/docs/deepdive/advanced/{guard.md → intercept.md} +87 -83
  18. data/docs/deepdive/features/builtin_tools.md +1 -1
  19. data/docs/deepdive/features/concurrency.md +15 -10
  20. data/docs/deepdive/features/database.md +19 -19
  21. data/docs/deepdive/features/embeddings.md +4 -4
  22. data/docs/deepdive/features/files.md +7 -5
  23. data/docs/deepdive/fundamentals/agents.md +13 -8
  24. data/docs/deepdive/fundamentals/providers.md +1 -1
  25. data/docs/deepdive/fundamentals/schema.md +2 -2
  26. data/docs/deepdive/fundamentals/stream.md +8 -8
  27. data/docs/deepdive/fundamentals/tools.md +14 -14
  28. data/docs/deepdive/media/ocr.md +1 -1
  29. data/docs/deepdive/protocols/a2a.md +3 -3
  30. data/docs/deepdive/protocols/mcp.md +116 -7
  31. data/docs/deepdive/reference/cost.md +1 -1
  32. data/docs/deepdive/reference/response.md +1 -1
  33. data/docs/deepdive/reference/tracer.md +90 -22
  34. data/docs/deepdive.md +1 -1
  35. data/lib/llm/agent/interrupt.rb +35 -46
  36. data/lib/llm/agent/registry.rb +106 -0
  37. data/lib/llm/agent.rb +242 -268
  38. data/lib/llm/context.rb +63 -55
  39. data/lib/llm/function/array.rb +2 -1
  40. data/lib/llm/function/async/group.rb +2 -2
  41. data/lib/llm/function/async/task.rb +25 -48
  42. data/lib/llm/function/fiber/group.rb +2 -2
  43. data/lib/llm/function/fiber/task.rb +16 -30
  44. data/lib/llm/function/fork/group.rb +2 -2
  45. data/lib/llm/function/fork/job.rb +8 -4
  46. data/lib/llm/function/fork/task.rb +25 -30
  47. data/lib/llm/function/group.rb +33 -5
  48. data/lib/llm/function/ractor/group.rb +2 -2
  49. data/lib/llm/function/ractor/job.rb +8 -6
  50. data/lib/llm/function/ractor/task.rb +32 -9
  51. data/lib/llm/function/sequential/group.rb +2 -1
  52. data/lib/llm/function/sequential/task.rb +8 -1
  53. data/lib/llm/function/task.rb +52 -4
  54. data/lib/llm/function/thread/group.rb +2 -2
  55. data/lib/llm/function/thread/task.rb +36 -10
  56. data/lib/llm/function/window.rb +16 -0
  57. data/lib/llm/function.rb +14 -43
  58. data/lib/llm/intercept/multi.rb +40 -0
  59. data/lib/llm/intercept/null.rb +18 -0
  60. data/lib/llm/intercept.rb +96 -0
  61. data/lib/llm/message.rb +1 -1
  62. data/lib/llm/provider.rb +16 -1
  63. data/lib/llm/providers/anthropic/stream_parser.rb +1 -1
  64. data/lib/llm/providers/bedrock/stream_parser.rb +1 -1
  65. data/lib/llm/providers/deepseek/files.rb +49 -0
  66. data/lib/llm/providers/deepseek/request_adapter/completion.rb +15 -13
  67. data/lib/llm/providers/deepseek.rb +16 -2
  68. data/lib/llm/providers/google/stream_parser.rb +1 -1
  69. data/lib/llm/providers/openai/responses/stream_parser.rb +1 -1
  70. data/lib/llm/providers/openai/stream_parser.rb +1 -1
  71. data/lib/llm/stream.rb +8 -7
  72. data/lib/llm/tool.rb +1 -1
  73. data/lib/llm/tools/utils.rb +1 -1
  74. data/lib/llm/tracer/logger.rb +42 -1
  75. data/lib/llm/tracer/multi.rb +144 -0
  76. data/lib/llm/tracer/null.rb +20 -0
  77. data/lib/llm/tracer/pretty_logger.rb +33 -2
  78. data/lib/llm/tracer/rescue.rb +110 -0
  79. data/lib/llm/tracer/telemetry.rb +69 -4
  80. data/lib/llm/tracer.rb +125 -48
  81. data/lib/llm/utils.rb +12 -2
  82. data/lib/llm/version.rb +1 -1
  83. data/lib/llm.rb +36 -1
  84. data/llm.gemspec +9 -4
  85. metadata +16 -35
  86. data/lib/llm/function/tracing.rb +0 -21
  87. data/lib/llm/guard/null.rb +0 -19
  88. data/lib/llm/guard.rb +0 -55
data/data/deepinfra.json CHANGED
@@ -7,6 +7,52 @@
7
7
  "name": "Deep Infra",
8
8
  "doc": "https://deepinfra.com/models",
9
9
  "models": {
10
+ "anthropic/claude-fable-5": {
11
+ "id": "anthropic/claude-fable-5",
12
+ "name": "Claude Fable 5",
13
+ "description": "Claude model for creative writing, analysis, and controlled agent workflows",
14
+ "family": "claude-fable",
15
+ "attachment": true,
16
+ "reasoning": true,
17
+ "reasoning_options": [
18
+ {
19
+ "type": "effort",
20
+ "values": [
21
+ "low",
22
+ "medium",
23
+ "high",
24
+ "xhigh",
25
+ "max"
26
+ ]
27
+ }
28
+ ],
29
+ "tool_call": true,
30
+ "structured_output": true,
31
+ "temperature": false,
32
+ "knowledge": "2026-01-31",
33
+ "release_date": "2026-06-09",
34
+ "last_updated": "2026-06-09",
35
+ "modalities": {
36
+ "input": [
37
+ "text",
38
+ "image",
39
+ "pdf"
40
+ ],
41
+ "output": [
42
+ "text"
43
+ ]
44
+ },
45
+ "open_weights": false,
46
+ "limit": {
47
+ "context": 1000000,
48
+ "output": 128000
49
+ },
50
+ "cost": {
51
+ "input": 10,
52
+ "output": 50
53
+ },
54
+ "canonical_model_id": "anthropic/claude-fable-5"
55
+ },
10
56
  "tencent/Hy3": {
11
57
  "id": "tencent/Hy3",
12
58
  "name": "Hy3",
@@ -34,6 +80,7 @@
34
80
  "input": 192000,
35
81
  "output": 128000
36
82
  },
83
+ "status": "deprecated",
37
84
  "cost": {
38
85
  "input": 0.13,
39
86
  "output": 0.53,
@@ -542,7 +589,7 @@
542
589
  "output": 32768
543
590
  },
544
591
  "cost": {
545
- "input": 0.15,
592
+ "input": 0.2,
546
593
  "output": 0.4
547
594
  },
548
595
  "canonical_model_id": "google/gemma-4-31b-it"
@@ -788,6 +835,38 @@
788
835
  },
789
836
  "canonical_model_id": "alibaba/qwen3.7-max"
790
837
  },
838
+ "Qwen/Qwen3-VL-30B-A3B-Instruct": {
839
+ "id": "Qwen/Qwen3-VL-30B-A3B-Instruct",
840
+ "name": "Qwen3 VL 30B A3B Instruct",
841
+ "description": "Open vision-language MoE model for image and video understanding, documents, and visual agents",
842
+ "family": "qwen",
843
+ "attachment": true,
844
+ "reasoning": false,
845
+ "tool_call": true,
846
+ "structured_output": true,
847
+ "temperature": true,
848
+ "release_date": "2025-10-04",
849
+ "last_updated": "2025-10-04",
850
+ "modalities": {
851
+ "input": [
852
+ "text",
853
+ "image"
854
+ ],
855
+ "output": [
856
+ "text"
857
+ ]
858
+ },
859
+ "open_weights": true,
860
+ "limit": {
861
+ "context": 262144,
862
+ "output": 32768
863
+ },
864
+ "cost": {
865
+ "input": 0.15,
866
+ "output": 0.6
867
+ },
868
+ "canonical_model_id": "alibaba/qwen3-vl-30b-a3b-instruct"
869
+ },
791
870
  "Qwen/Qwen3.8-Max": {
792
871
  "id": "Qwen/Qwen3.8-Max",
793
872
  "name": "Qwen3.8 Max",
@@ -950,6 +1029,7 @@
950
1029
  "context": 256000,
951
1030
  "output": 65536
952
1031
  },
1032
+ "status": "deprecated",
953
1033
  "cost": {
954
1034
  "input": 1.2,
955
1035
  "output": 6,
@@ -1249,6 +1329,7 @@
1249
1329
  "context": 262144,
1250
1330
  "output": 131072
1251
1331
  },
1332
+ "status": "deprecated",
1252
1333
  "cost": {
1253
1334
  "input": 2,
1254
1335
  "output": 6,
@@ -1805,6 +1886,48 @@
1805
1886
  },
1806
1887
  "canonical_model_id": "stepfun/step-3.7-flash"
1807
1888
  },
1889
+ "stepfun-ai/Step-5-Preview": {
1890
+ "id": "stepfun-ai/Step-5-Preview",
1891
+ "name": "Step 5 Preview",
1892
+ "description": "StepFun's next-generation flagship base model for coding and professional knowledge work, with native text, image, and video input and a 1M-token context window",
1893
+ "attachment": true,
1894
+ "reasoning": true,
1895
+ "reasoning_options": [
1896
+ {
1897
+ "type": "effort",
1898
+ "values": [
1899
+ "low",
1900
+ "medium",
1901
+ "high"
1902
+ ]
1903
+ }
1904
+ ],
1905
+ "tool_call": true,
1906
+ "structured_output": true,
1907
+ "release_date": "2026-09-16",
1908
+ "last_updated": "2026-09-20",
1909
+ "modalities": {
1910
+ "input": [
1911
+ "text",
1912
+ "image",
1913
+ "video"
1914
+ ],
1915
+ "output": [
1916
+ "text"
1917
+ ]
1918
+ },
1919
+ "open_weights": false,
1920
+ "limit": {
1921
+ "context": 1048576,
1922
+ "output": 1000000
1923
+ },
1924
+ "cost": {
1925
+ "input": 1,
1926
+ "output": 2.7,
1927
+ "cache_read": 0.1
1928
+ },
1929
+ "canonical_model_id": "stepfun/step-5-preview"
1930
+ },
1808
1931
  "MiniMaxAI/MiniMax-M3": {
1809
1932
  "id": "MiniMaxAI/MiniMax-M3",
1810
1933
  "name": "MiniMax-M3",
@@ -1909,6 +2032,38 @@
1909
2032
  },
1910
2033
  "canonical_model_id": "minimax/MiniMax-M2.7"
1911
2034
  },
2035
+ "mistralai/Mistral-Small-24B-Instruct-2501": {
2036
+ "id": "mistralai/Mistral-Small-24B-Instruct-2501",
2037
+ "name": "Mistral Small 3",
2038
+ "description": "Efficient Mistral model for fast chat, extraction, and production assistants",
2039
+ "family": "mistral-small",
2040
+ "attachment": false,
2041
+ "reasoning": false,
2042
+ "tool_call": false,
2043
+ "structured_output": true,
2044
+ "temperature": true,
2045
+ "knowledge": "2023-10-31",
2046
+ "release_date": "2025-01-30",
2047
+ "last_updated": "2025-01-30",
2048
+ "modalities": {
2049
+ "input": [
2050
+ "text"
2051
+ ],
2052
+ "output": [
2053
+ "text"
2054
+ ]
2055
+ },
2056
+ "open_weights": true,
2057
+ "limit": {
2058
+ "context": 32768,
2059
+ "output": 16384
2060
+ },
2061
+ "cost": {
2062
+ "input": 0.05,
2063
+ "output": 0.08
2064
+ },
2065
+ "canonical_model_id": "mistral/mistral-small-24b-instruct-2501"
2066
+ },
1912
2067
  "moonshotai/Kimi-K2.6": {
1913
2068
  "id": "moonshotai/Kimi-K2.6",
1914
2069
  "name": "Kimi K2.6",
@@ -2445,6 +2600,7 @@
2445
2600
  "context": 262144,
2446
2601
  "output": 262144
2447
2602
  },
2603
+ "status": "deprecated",
2448
2604
  "cost": {
2449
2605
  "input": 0.05,
2450
2606
  "output": 0.2,
data/data/google.json CHANGED
@@ -1601,6 +1601,54 @@
1601
1601
  },
1602
1602
  "canonical_model_id": "google/gemini-3.1-flash-live-preview"
1603
1603
  },
1604
+ "gemini-4-argon": {
1605
+ "id": "gemini-4-argon",
1606
+ "name": "Gemini 4 Argon",
1607
+ "description": "Google's flagship reasoning model for complex software engineering, deep math and science, and long-horizon autonomous agents",
1608
+ "family": "gemini",
1609
+ "attachment": true,
1610
+ "reasoning": true,
1611
+ "reasoning_options": [
1612
+ {
1613
+ "type": "effort",
1614
+ "values": [
1615
+ "low",
1616
+ "medium",
1617
+ "high"
1618
+ ]
1619
+ }
1620
+ ],
1621
+ "tool_call": true,
1622
+ "structured_output": true,
1623
+ "temperature": true,
1624
+ "knowledge": "2026-03",
1625
+ "release_date": "2026-10-13",
1626
+ "last_updated": "2026-10-13",
1627
+ "modalities": {
1628
+ "input": [
1629
+ "text",
1630
+ "image",
1631
+ "video",
1632
+ "audio",
1633
+ "pdf"
1634
+ ],
1635
+ "output": [
1636
+ "text"
1637
+ ]
1638
+ },
1639
+ "open_weights": false,
1640
+ "limit": {
1641
+ "context": 1048576,
1642
+ "output": 32768
1643
+ },
1644
+ "cost": {
1645
+ "input": 2,
1646
+ "output": 10,
1647
+ "cache_read": 0.1,
1648
+ "input_audio": 2
1649
+ },
1650
+ "canonical_model_id": "google/gemini-4-argon"
1651
+ },
1604
1652
  "gemini-3.1-flash-lite": {
1605
1653
  "id": "gemini-3.1-flash-lite",
1606
1654
  "name": "Gemini 3.1 Flash Lite",