jtc-core 0.3.0__py3-none-any.whl

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 (226) hide show
  1. jtc/__init__.py +5 -0
  2. jtc/common/__init__.py +259 -0
  3. jtc/common/asset_store.py +9 -0
  4. jtc/common/chat_completion.py +97 -0
  5. jtc/common/cli.py +151 -0
  6. jtc/common/code_execution.py +443 -0
  7. jtc/common/code_utils.py +252 -0
  8. jtc/common/generation_workflow.py +404 -0
  9. jtc/common/hub.py +26 -0
  10. jtc/common/ifeval/__init__.py +11 -0
  11. jtc/common/ifeval/functions.py +1161 -0
  12. jtc/common/jrecord_sampling.py +201 -0
  13. jtc/common/jrow_regrouping.py +274 -0
  14. jtc/common/jrow_sampling.py +222 -0
  15. jtc/common/parquet.py +500 -0
  16. jtc/common/podman_verifier.py +209 -0
  17. jtc/common/prime_rl_dataset.py +180 -0
  18. jtc/common/process.py +47 -0
  19. jtc/common/rejection_sampling.py +252 -0
  20. jtc/common/resources/__init__.py +1 -0
  21. jtc/common/resources/templates/answer-generation.json +14 -0
  22. jtc/common/resources/templates/articulated_harness_gptoss.json +18 -0
  23. jtc/common/resources/templates/code-check-generation.json +15 -0
  24. jtc/common/resources/templates/code-check-label-generation-gptoss.json +35 -0
  25. jtc/common/resources/templates/extraction-prompt-generation.json +15 -0
  26. jtc/common/resources/templates/jtc-io-complete.json +37 -0
  27. jtc/common/resources/templates/jtc-io-prompt.json +20 -0
  28. jtc/common/resources/templates/jtc-io-python-prompt-gptoss-harmony.json +20 -0
  29. jtc/common/resources/templates/jtc-io-repl-prompt-gptoss-harmony.json +19 -0
  30. jtc/common/resources/templates/jtc-io-repl-prompt-v4.json +19 -0
  31. jtc/common/resources/templates/jtc-io-simple-prompt-json.json +20 -0
  32. jtc/common/resources/templates/jtc-io-simple-prompt.json +20 -0
  33. jtc/common/resources/templates/jtc-io-terminal-prompt-gptoss-harmony.json +19 -0
  34. jtc/common/resources/templates/jtc-io-terminal-release-browse-search-xml-v1.json +56 -0
  35. jtc/common/resources/templates/jtc-io-terminal-release-browse-xml-v1.json +36 -0
  36. jtc/common/resources/templates/jtc-io-terminal-release-browse.json +36 -0
  37. jtc/common/resources/templates/jtc-io-terminal-release.json +19 -0
  38. jtc/common/resources/templates/jtc-io-tool_response.json +31 -0
  39. jtc/common/resources/templates/multistep-final-warning-harmony.json +14 -0
  40. jtc/common/resources/templates/multistep-final-warning.json +13 -0
  41. jtc/common/resources/templates/multistep-tool-message.json +13 -0
  42. jtc/common/resources/templates/recordset-batch-rubric-judge.json +19 -0
  43. jtc/common/resources/templates/rubric-generation-from-rollouts.json +19 -0
  44. jtc/common/resources/templates/rubric-generation-from-unit-tests.json +15 -0
  45. jtc/common/resources/templates/search-agent-visit-judge.json +15 -0
  46. jtc/common/resources/templates/search-agent-visit.json +15 -0
  47. jtc/common/resources/templates/search-agent-webterminal-10k.json +17 -0
  48. jtc/common/resources/templates/search-agent.json +17 -0
  49. jtc/common/resources/templates/tmax-podman-trace-submit-binary-gptoss.v2.json +13 -0
  50. jtc/common/resources/templates/tmax-podman-trace-submit-gptoss.json +41 -0
  51. jtc/common/resources/templates/wildguard-instance-rubric-generation.json +21 -0
  52. jtc/common/rubric_execution.py +179 -0
  53. jtc/common/schema.py +455 -0
  54. jtc/common/scoring.py +62 -0
  55. jtc/common/sources/__init__.py +202 -0
  56. jtc/common/sources/base.py +27 -0
  57. jtc/common/sources/coding.py +234 -0
  58. jtc/common/sources/coding_transform.py +53 -0
  59. jtc/common/sources/common.py +236 -0
  60. jtc/common/sources/deepresearch_bench.py +103 -0
  61. jtc/common/sources/drtulu.py +107 -0
  62. jtc/common/sources/drtulu_code_checks.py +165 -0
  63. jtc/common/sources/gpqa.py +146 -0
  64. jtc/common/sources/healthbench.py +113 -0
  65. jtc/common/sources/ifeval.py +151 -0
  66. jtc/common/sources/ifeval_transform.py +54 -0
  67. jtc/common/sources/liveresearchbench.py +96 -0
  68. jtc/common/sources/llmeval_med.py +267 -0
  69. jtc/common/sources/medqa_usmle.py +121 -0
  70. jtc/common/sources/mind2web2.py +145 -0
  71. jtc/common/sources/mmlu_pro.py +118 -0
  72. jtc/common/sources/monaco.py +334 -0
  73. jtc/common/sources/multiple_choice.py +108 -0
  74. jtc/common/sources/natural.py +90 -0
  75. jtc/common/sources/natural_synth.py +186 -0
  76. jtc/common/sources/openrubrics.py +99 -0
  77. jtc/common/sources/prbench.py +153 -0
  78. jtc/common/sources/profbench.py +131 -0
  79. jtc/common/sources/prometheus.py +65 -0
  80. jtc/common/sources/quest.py +336 -0
  81. jtc/common/sources/researchqa.py +405 -0
  82. jtc/common/sources/rubricbench.py +111 -0
  83. jtc/common/sources/ruft26k.py +140 -0
  84. jtc/common/sources/ruft26k_answer_generations.py +302 -0
  85. jtc/common/sources/ruft26k_code_checks.py +156 -0
  86. jtc/common/sources/science_qwen35_judgments.py +80 -0
  87. jtc/common/sources/tbd.py +29 -0
  88. jtc/common/sources/wildbench.py +271 -0
  89. jtc/common/submission.py +19 -0
  90. jtc/common/submission_display.py +28 -0
  91. jtc/common/templates.py +158 -0
  92. jtc/common/tmax_replay.py +157 -0
  93. jtc/common/tool_clients.py +74 -0
  94. jtc/common/tool_specs.py +111 -0
  95. jtc/common/trace_inspection.py +69 -0
  96. jtc/common/utils.py +80 -0
  97. jtc/common/workflows/__init__.py +9 -0
  98. jtc/common/workflows/__main__.py +3 -0
  99. jtc/common/workflows/answer_generation_workflow.py +499 -0
  100. jtc/common/workflows/cli.py +32 -0
  101. jtc/common/workflows/code_addressability_workflow.py +186 -0
  102. jtc/common/workflows/code_check_generation_workflow.py +912 -0
  103. jtc/common/workflows/code_check_label_generation_workflow.py +403 -0
  104. jtc/common/workflows/extraction_prompt_generation_workflow.py +314 -0
  105. jtc/common/workflows/inference_workflow.py +1431 -0
  106. jtc/common/workflows/jrecord_batch_rubric_judgment_workflow.py +231 -0
  107. jtc/common/workflows/logprob_workflow.py +375 -0
  108. jtc/common/workflows/multi_step_generation_workflow.py +654 -0
  109. jtc/common/workflows/multi_step_workflow.py +810 -0
  110. jtc/common/workflows/process_message_workers.py +156 -0
  111. jtc/common/workflows/registry.py +56 -0
  112. jtc/common/workflows/science_bundles_batch_rubric_judgment_workflow.py +438 -0
  113. jtc/common/workflows/science_bundles_rubric_generation_workflow.py +376 -0
  114. jtc/common/workflows/search_agent_rollout_workflow.py +891 -0
  115. jtc/common/workflows/tmax_unit_test_rubric_generation_workflow.py +86 -0
  116. jtc/common/workflows/tmax_unit_test_rubric_generation_workflow_v2.py +121 -0
  117. jtc/common/workflows/tmax_unit_test_rubric_generation_workflow_v3.py +50 -0
  118. jtc/common/workflows/tool_use_generation_workflow.py +478 -0
  119. jtc/common/workflows/tool_use_workflow.py +955 -0
  120. jtc/common/workflows/verifier_articulated_grouped_submit_smoke.py +92 -0
  121. jtc/common/workflows/verifier_articulated_submit_tool_use_workflow.py +37 -0
  122. jtc/common/workflows/verifier_articulated_submit_tool_use_workflow_v2.py +37 -0
  123. jtc/common/workflows/verifier_submit_tool_use_workflow.py +164 -0
  124. jtc/common/workflows/verifier_tmax_podman_binary_submit_workflow.py +59 -0
  125. jtc/common/workflows/verifier_tmax_podman_binary_submit_workflow_v3.py +36 -0
  126. jtc/common/workflows/verifier_tmax_podman_submit_workflow.py +330 -0
  127. jtc/common/workflows/verifier_tmax_podman_submit_workflow_v3.py +47 -0
  128. jtc/common/workflows/verifier_tool_use_workflow.py +985 -0
  129. jtc/common/workflows/wildguard_rubric_generation_workflow.py +314 -0
  130. jtc/datadev/__init__.py +24 -0
  131. jtc/datadev/cli.py +220 -0
  132. jtc/datadev/data/__init__.py +29 -0
  133. jtc/datadev/data/materialize.py +1466 -0
  134. jtc/datadev/data/recipes.py +311 -0
  135. jtc/datadev/infra/__init__.py +3 -0
  136. jtc/datadev/infra/bm25_server.py +358 -0
  137. jtc/datadev/literegistry/__init__.py +1 -0
  138. jtc/datadev/literegistry/gateway.py +430 -0
  139. jtc/datadev/literegistry/jina_reader.py +222 -0
  140. jtc/datadev/opt/__init__.py +5 -0
  141. jtc/datadev/opt/weights.py +245 -0
  142. jtc/datadev/pot_sampling.py +303 -0
  143. jtc/datadev/pots.py +238 -0
  144. jtc/datadev/raw_token_prior.py +364 -0
  145. jtc/datadev/semaphore/__init__.py +23 -0
  146. jtc/datadev/semaphore/__main__.py +199 -0
  147. jtc/datadev/semaphore/core.py +825 -0
  148. jtc/datadev/sft_pot_batches.py +444 -0
  149. jtc/datadev/token_counts.py +41 -0
  150. jtc/datadev/training_config.py +560 -0
  151. jtc/datadev/workflows.py +88 -0
  152. jtc/eval/__init__.py +31 -0
  153. jtc/eval/__main__.py +5 -0
  154. jtc/eval/benchmark.py +264 -0
  155. jtc/eval/bon_config.py +242 -0
  156. jtc/eval/bon_plot.py +325 -0
  157. jtc/eval/cli.py +53 -0
  158. jtc/eval/dashboard.py +18 -0
  159. jtc/eval/eval.py +569 -0
  160. jtc/eval/evalboard/__init__.py +5 -0
  161. jtc/eval/evalboard/__main__.py +50 -0
  162. jtc/eval/evalboard/export.py +67 -0
  163. jtc/eval/evalboard/site/.openai/hosting.json +5 -0
  164. jtc/eval/evalboard/site/README.md +56 -0
  165. jtc/eval/evalboard/site/app/bon/bon.module.css +108 -0
  166. jtc/eval/evalboard/site/app/bon/page.tsx +234 -0
  167. jtc/eval/evalboard/site/app/chatgpt-auth.ts +90 -0
  168. jtc/eval/evalboard/site/app/globals.css +56 -0
  169. jtc/eval/evalboard/site/app/globals.v10.css +14 -0
  170. jtc/eval/evalboard/site/app/globals.v11.css +12 -0
  171. jtc/eval/evalboard/site/app/globals.v12.css +12 -0
  172. jtc/eval/evalboard/site/app/globals.v13.css +49 -0
  173. jtc/eval/evalboard/site/app/globals.v14.css +3 -0
  174. jtc/eval/evalboard/site/app/globals.v15.css +19 -0
  175. jtc/eval/evalboard/site/app/globals.v16.css +18 -0
  176. jtc/eval/evalboard/site/app/globals.v17.css +20 -0
  177. jtc/eval/evalboard/site/app/globals.v18.css +7 -0
  178. jtc/eval/evalboard/site/app/globals.v19.css +17 -0
  179. jtc/eval/evalboard/site/app/globals.v20.css +42 -0
  180. jtc/eval/evalboard/site/app/globals.v6.css +2 -0
  181. jtc/eval/evalboard/site/app/globals.v7.css +15 -0
  182. jtc/eval/evalboard/site/app/globals.v8.css +15 -0
  183. jtc/eval/evalboard/site/app/globals.v9.css +29 -0
  184. jtc/eval/evalboard/site/app/layout.tsx +11 -0
  185. jtc/eval/evalboard/site/app/page.tsx +12 -0
  186. jtc/eval/evalboard/site/build/sites-vite-plugin.ts +45 -0
  187. jtc/eval/evalboard/site/db/index.ts +13 -0
  188. jtc/eval/evalboard/site/db/schema.ts +4 -0
  189. jtc/eval/evalboard/site/drizzle.config.ts +7 -0
  190. jtc/eval/evalboard/site/eslint.config.mjs +41 -0
  191. jtc/eval/evalboard/site/next-env.d.ts +5 -0
  192. jtc/eval/evalboard/site/next.config.ts +7 -0
  193. jtc/eval/evalboard/site/package-lock.json +10279 -0
  194. jtc/eval/evalboard/site/package.json +47 -0
  195. jtc/eval/evalboard/site/postcss.config.mjs +7 -0
  196. jtc/eval/evalboard/site/public/favicon.svg +6 -0
  197. jtc/eval/evalboard/site/public/file.svg +1 -0
  198. jtc/eval/evalboard/site/public/globe.svg +1 -0
  199. jtc/eval/evalboard/site/public/og.png +0 -0
  200. jtc/eval/evalboard/site/public/window.svg +1 -0
  201. jtc/eval/evalboard/site/tests/rendered-html.test.mjs +91 -0
  202. jtc/eval/evalboard/site/tsconfig.json +29 -0
  203. jtc/eval/evalboard/site/vite.config.ts +59 -0
  204. jtc/eval/evalboard/site/worker/index.ts +47 -0
  205. jtc/eval/inference_scaling.py +203 -0
  206. jtc/eval/jina_reader.py +222 -0
  207. jtc/eval/launcher.py +54 -0
  208. jtc/eval/outcomes.py +262 -0
  209. jtc/eval/plot.py +159 -0
  210. jtc/eval/reconstruct_rubricbench_jrecords.py +578 -0
  211. jtc/eval/rejection_sampling.py +61 -0
  212. jtc/eval/rejection_sampling_worker.py +177 -0
  213. jtc/eval/rubric_judge_audit.py +224 -0
  214. jtc/eval/rubric_judge_audit_worker.py +145 -0
  215. jtc/eval/search_agent.py +63 -0
  216. jtc/eval/search_worker.py +75 -0
  217. jtc/eval/trace_rubric_recovery.py +298 -0
  218. jtc/eval/trace_rubric_sampling.py +594 -0
  219. jtc/eval/worker.py +52 -0
  220. jtc/eval/workflow.py +37 -0
  221. jtc/eval/workflow_worker.py +104 -0
  222. jtc_core-0.3.0.dist-info/METADATA +366 -0
  223. jtc_core-0.3.0.dist-info/RECORD +226 -0
  224. jtc_core-0.3.0.dist-info/WHEEL +5 -0
  225. jtc_core-0.3.0.dist-info/entry_points.txt +8 -0
  226. jtc_core-0.3.0.dist-info/top_level.txt +1 -0
jtc/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ """Unified JTC data, evaluation, and configuration toolkit."""
2
+
3
+ from __future__ import annotations
4
+
5
+ __all__ = ["common", "datadev", "eval"]
jtc/common/__init__.py ADDED
@@ -0,0 +1,259 @@
1
+ """Common schema and IO helpers for Judges That Code datasets."""
2
+
3
+ from importlib import import_module
4
+ from typing import Any
5
+
6
+ from jtcflow.model import Assertion, LLMResponse
7
+
8
+ from jtc.common.schema import (
9
+ BINARY_RUBRIC_SCORES,
10
+ CodeExecution,
11
+ FeedbackExecutableRubricJudgment,
12
+ ExecutableRubricJudgment,
13
+ ExecutableRubric,
14
+ JRecordSet,
15
+ JRecord,
16
+ JRow,
17
+ JTask,
18
+ MultiStepCodeStep,
19
+ MultiStepRubricJudgment,
20
+ MultiStepRubricTurn,
21
+ RubricJudgment,
22
+ RubricItem,
23
+ SerializableRubric,
24
+ RubricDefinition,
25
+ RubricType,
26
+ SourceInfo,
27
+ )
28
+ from jtc.common.templates import (
29
+ HasFeedbackLabel,
30
+ coerce_chat_messages,
31
+ format_rubric_dict,
32
+ load_prompt_template,
33
+ parse_feedback_label,
34
+ render_chat_template,
35
+ resolve_resource_path,
36
+ )
37
+ from jtc.common.parquet import (
38
+ examples_to_dataset,
39
+ examples_to_rows,
40
+ jrow_from_dict,
41
+ load_parquet_objects,
42
+ read_parquet,
43
+ write_parquet,
44
+ )
45
+ from jtc.common.scoring import (
46
+ RubricScorer,
47
+ UniformScorer,
48
+ )
49
+
50
+ _LAZY_EXPORTS = {
51
+ "sample_jrecords": ("jtc.common.jrecord_sampling", "sample_jrecords"),
52
+ "sample_jrecords_file": (
53
+ "jtc.common.jrecord_sampling",
54
+ "sample_jrecords_file",
55
+ ),
56
+ "selected_output_indexes": (
57
+ "jtc.common.jrecord_sampling",
58
+ "selected_output_indexes",
59
+ ),
60
+ "sample_jrows": ("jtc.common.jrow_sampling", "sample_jrows"),
61
+ "sample_jrows_file": ("jtc.common.jrow_sampling", "sample_jrows_file"),
62
+ "selected_indexes": ("jtc.common.jrow_sampling", "selected_indexes"),
63
+ "AssetStore": ("literegistry_tool_client", "AssetStore"),
64
+ "WebAssetStore": ("literegistry_tool_client", "WebAssetStore"),
65
+ "CodeExecutionMap": ("jtc.common.code_execution", "CodeExecutionMap"),
66
+ "WebTerminalExecutionClient": (
67
+ "literegistry_tool_client",
68
+ "WebTerminalExecutionClient",
69
+ ),
70
+ "FetchClient": ("literegistry_tool_client", "FetchClient"),
71
+ "JudgeClient": ("literegistry_tool_client", "JudgeClient"),
72
+ "MultiToolExecutionMap": (
73
+ "jtc.common.code_execution",
74
+ "MultiToolExecutionMap",
75
+ ),
76
+ "ParallelMultiToolExecutionMap": (
77
+ "jtc.common.code_execution",
78
+ "ParallelMultiToolExecutionMap",
79
+ ),
80
+ "PodmanExecutionClient": (
81
+ "literegistry_tool_client",
82
+ "PodmanExecutionClient",
83
+ ),
84
+ "RemoteCodeExecutionClient": (
85
+ "jtc.common.code_execution",
86
+ "RemoteCodeExecutionClient",
87
+ ),
88
+ "SearchClient": ("literegistry_tool_client", "SearchClient"),
89
+ "TerminalExecutionClient": (
90
+ "literegistry_tool_client",
91
+ "TerminalExecutionClient",
92
+ ),
93
+ "ToolClient": ("literegistry_tool_client", "ToolClient"),
94
+ "SubmissionStore": ("literegistry_tool_client", "SubmissionStore"),
95
+ "SubmitToolClient": ("literegistry_tool_client", "SubmitToolClient"),
96
+ "ToolExecutionMap": ("jtc.common.code_execution", "ToolExecutionMap"),
97
+ "ToolOutputDisplay": ("literegistry_tool_client", "ToolOutputDisplay"),
98
+ "fast_forward_container_state": (
99
+ "jtc.common.tmax_replay",
100
+ "fast_forward_container_state",
101
+ ),
102
+ "ContextBoundPodmanTerminalClient": (
103
+ "jtc.common.podman_verifier",
104
+ "ContextBoundPodmanTerminalClient",
105
+ ),
106
+ "PodmanVerifierConfig": (
107
+ "jtc.common.podman_verifier",
108
+ "PodmanVerifierConfig",
109
+ ),
110
+ "PodmanVerifierHarness": (
111
+ "jtc.common.podman_verifier",
112
+ "PodmanVerifierHarness",
113
+ ),
114
+ "PodmanVerifierRun": (
115
+ "jtc.common.podman_verifier",
116
+ "PodmanVerifierRun",
117
+ ),
118
+ "FencedToolOutputDisplay": ("literegistry_tool_client", "FencedToolOutputDisplay"),
119
+ "PlainJsonToolOutputDisplay": ("literegistry_tool_client", "PlainJsonToolOutputDisplay"),
120
+ "ExecutableRowProcessor": ("jtc.common.process", "ExecutableRowProcessor"),
121
+ "GenerationWorkflowSpec": (
122
+ "jtc.common.generation_workflow",
123
+ "GenerationWorkflowSpec",
124
+ ),
125
+ "GenericGenerationWorkflow": (
126
+ "jtc.common.generation_workflow",
127
+ "GenericGenerationWorkflow",
128
+ ),
129
+ "execute_executable_rubric_async": (
130
+ "jtc.common.rubric_execution",
131
+ "execute_executable_rubric_async",
132
+ ),
133
+ "execute_executable_row_async": (
134
+ "jtc.common.rubric_execution",
135
+ "execute_executable_row_async",
136
+ ),
137
+ "execute_record_async": ("jtc.common.rubric_execution", "execute_record_async"),
138
+ "executable_judgment_from_code_output": (
139
+ "jtc.common.rubric_execution",
140
+ "executable_judgment_from_code_output",
141
+ ),
142
+ "get_verification_results": (
143
+ "jtc.common.rubric_execution",
144
+ "get_verification_results",
145
+ ),
146
+ "load_input_rows": ("jtc.common.generation_workflow", "load_input_rows"),
147
+ "process_executable_record_async": (
148
+ "jtc.common.process",
149
+ "process_executable_record_async",
150
+ ),
151
+ "process_executable_rows_async": (
152
+ "jtc.common.process",
153
+ "process_executable_rows_async",
154
+ ),
155
+ "run_generation_workflow": (
156
+ "jtc.common.generation_workflow",
157
+ "run_generation_workflow",
158
+ ),
159
+ "start_literegistry_gateway": (
160
+ "jtc.common.generation_workflow",
161
+ "start_literegistry_gateway",
162
+ ),
163
+ "workflow_inputs_from_rows": (
164
+ "jtc.common.generation_workflow",
165
+ "workflow_inputs_from_rows",
166
+ ),
167
+ "write_jsonl": ("jtc.common.generation_workflow", "write_jsonl"),
168
+ }
169
+
170
+
171
+ def __getattr__(name: str) -> Any:
172
+ if name not in _LAZY_EXPORTS:
173
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
174
+ module_name, attr_name = _LAZY_EXPORTS[name]
175
+ value = getattr(import_module(module_name), attr_name)
176
+ globals()[name] = value
177
+ return value
178
+
179
+
180
+ __all__ = [
181
+ "AssetStore",
182
+ "WebTerminalExecutionClient",
183
+ "BINARY_RUBRIC_SCORES",
184
+ "CodeExecution",
185
+ "CodeExecutionMap",
186
+ "FeedbackExecutableRubricJudgment",
187
+ "FetchClient",
188
+ "JudgeClient",
189
+ "ExecutableRubricJudgment",
190
+ "ExecutableRubric",
191
+ "JRecordSet",
192
+ "JRecord",
193
+ "JRow",
194
+ "JTask",
195
+ "MultiStepCodeStep",
196
+ "MultiStepRubricJudgment",
197
+ "MultiStepRubricTurn",
198
+ "MultiToolExecutionMap",
199
+ "ParallelMultiToolExecutionMap",
200
+ "PodmanExecutionClient",
201
+ "RubricJudgment",
202
+ "RubricItem",
203
+ "SerializableRubric",
204
+ "RubricDefinition",
205
+ "RubricType",
206
+ "SourceInfo",
207
+ "RemoteCodeExecutionClient",
208
+ "SearchClient",
209
+ "TerminalExecutionClient",
210
+ "ToolClient",
211
+ "SubmissionStore",
212
+ "SubmitToolClient",
213
+ "ToolExecutionMap",
214
+ "ToolOutputDisplay",
215
+ "fast_forward_container_state",
216
+ "ContextBoundPodmanTerminalClient",
217
+ "PodmanVerifierConfig",
218
+ "PodmanVerifierHarness",
219
+ "PodmanVerifierRun",
220
+ "FencedToolOutputDisplay",
221
+ "PlainJsonToolOutputDisplay",
222
+ "execute_executable_rubric_async",
223
+ "execute_executable_row_async",
224
+ "execute_record_async",
225
+ "executable_judgment_from_code_output",
226
+ "get_verification_results",
227
+ "ExecutableRowProcessor",
228
+ "process_executable_record_async",
229
+ "process_executable_rows_async",
230
+ "HasFeedbackLabel",
231
+ "coerce_chat_messages",
232
+ "format_rubric_dict",
233
+ "load_prompt_template",
234
+ "parse_feedback_label",
235
+ "render_chat_template",
236
+ "resolve_resource_path",
237
+ "GenerationWorkflowSpec",
238
+ "GenericGenerationWorkflow",
239
+ "load_input_rows",
240
+ "run_generation_workflow",
241
+ "workflow_inputs_from_rows",
242
+ "write_jsonl",
243
+ "examples_to_dataset",
244
+ "examples_to_rows",
245
+ "jrow_from_dict",
246
+ "load_parquet_objects",
247
+ "read_parquet",
248
+ "write_parquet",
249
+ "sample_jrecords",
250
+ "sample_jrecords_file",
251
+ "selected_output_indexes",
252
+ "sample_jrows",
253
+ "sample_jrows_file",
254
+ "selected_indexes",
255
+ "RubricScorer",
256
+ "UniformScorer",
257
+ "WebAssetStore",
258
+ "start_literegistry_gateway",
259
+ ]
@@ -0,0 +1,9 @@
1
+ """Compatibility exports for the canonical LiteRegistry asset stores."""
2
+
3
+ from literegistry_tool_client import (
4
+ AssetStore,
5
+ WebAssetStore,
6
+ normalize_web_page_content,
7
+ )
8
+
9
+ __all__ = ["AssetStore", "WebAssetStore", "normalize_web_page_content"]
@@ -0,0 +1,97 @@
1
+ """OpenAI-compatible chat-completions client for local and hosted models."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import asyncio
6
+ import os
7
+ from typing import Any
8
+
9
+ from jtcflow.model import ChatGPTClient
10
+
11
+
12
+ def chat_base_url(server_url: str) -> str:
13
+ """Return an OpenAI API base URL without duplicating the ``/v1`` suffix."""
14
+ base = str(server_url).rstrip("/")
15
+ return base if base.endswith("/v1") else f"{base}/v1"
16
+
17
+
18
+ class ChatCompletionClient(ChatGPTClient):
19
+ """JTCFlow chat client with the former local-client constructor shape.
20
+
21
+ Local LiteRegistry/vLLM deployments expose the OpenAI-compatible
22
+ ``/v1/chat/completions`` endpoint. Keeping this small adapter lets existing
23
+ workflows migrate without rendering prompts or parsing model-specific wire
24
+ formats in JTC.
25
+ """
26
+
27
+ def __init__(
28
+ self,
29
+ server_url: str,
30
+ model_path: str,
31
+ max_new_tokens: int = 1024,
32
+ max_prompt_length: int = 3072,
33
+ stop_tokens: list[str] | None = None,
34
+ temperature: float = 1.0,
35
+ timeout: float = 300,
36
+ max_retries: int = 15,
37
+ max_concurrent_requests: int = 256,
38
+ tokenizer_path: str | None = None,
39
+ enable_thinking: bool = False,
40
+ tools: list[dict[str, Any]] | None = None,
41
+ api_key: str | None = None,
42
+ reasoning_effort: str | None = None,
43
+ ) -> None:
44
+ # Retain these attributes for workflow diagnostics and compatibility.
45
+ self.server_url = str(server_url).rstrip("/")
46
+ self.max_prompt_length = max_prompt_length
47
+ self.tokenizer_path = tokenizer_path
48
+ self.temperature = temperature
49
+ self.enable_thinking = enable_thinking
50
+ super().__init__(
51
+ api_key=api_key or os.getenv("OPENAI_API_KEY") or "local",
52
+ model=model_path,
53
+ max_new_tokens=max_new_tokens,
54
+ stop_tokens=stop_tokens,
55
+ timeout=timeout,
56
+ max_retries=max_retries,
57
+ max_concurrent_requests=max_concurrent_requests,
58
+ base_url=chat_base_url(server_url),
59
+ tools=tools,
60
+ reasoning_effort=reasoning_effort,
61
+ )
62
+
63
+ async def _make_request_with_semaphore(
64
+ self,
65
+ semaphore: asyncio.Semaphore,
66
+ messages: list[dict[str, Any]],
67
+ n: int = 1,
68
+ ) -> Any:
69
+ """Issue one chat-completions request with local vLLM options."""
70
+ async with semaphore:
71
+ kwargs: dict[str, Any] = {
72
+ "model": self.model,
73
+ "messages": messages,
74
+ "max_completion_tokens": self.max_new_tokens,
75
+ "n": n,
76
+ "temperature": self.temperature,
77
+ "extra_body": {
78
+ "chat_template_kwargs": {
79
+ "enable_thinking": self.enable_thinking,
80
+ }
81
+ },
82
+ }
83
+ if self.stop_tokens:
84
+ kwargs["stop"] = self.stop_tokens
85
+ if self.tools is not None:
86
+ kwargs["tools"] = self.tools
87
+ kwargs["tool_choice"] = "auto"
88
+ effort = self._chat_completions_reasoning_effort()
89
+ if effort is not None:
90
+ kwargs["reasoning_effort"] = effort
91
+ try:
92
+ return await self.client.chat.completions.create(**kwargs)
93
+ except Exception as exc:
94
+ raise RuntimeError(f"Chat completions request failed: {exc}") from exc
95
+
96
+
97
+ __all__ = ["ChatCompletionClient", "chat_base_url"]
jtc/common/cli.py ADDED
@@ -0,0 +1,151 @@
1
+ """Command line helpers for inspecting JTC data files."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import textwrap
7
+ from pathlib import Path
8
+ from typing import Any
9
+
10
+ import fire
11
+
12
+ from jtc.common.jrow_sampling import sample_jrows_file
13
+ from jtc.common.jrecord_sampling import sample_jrecords_file
14
+ from jtc.common.parquet import DataRecord, load_parquet_objects
15
+ from jtc.common.schema import JRecord, JRow
16
+
17
+
18
+ def _shorten(value: Any, *, width: int = 1000) -> str:
19
+ if value is None:
20
+ return ""
21
+ text = str(value)
22
+ if "\n" in text:
23
+ return text if len(text) <= width else text[: width - 4] + " ..."
24
+ return textwrap.shorten(
25
+ text,
26
+ width=width,
27
+ placeholder=" ...",
28
+ )
29
+
30
+
31
+ def _first_jrow(objects: list[DataRecord]) -> JRow | None:
32
+ for obj in objects:
33
+ if isinstance(obj, JRow):
34
+ return obj
35
+ if isinstance(obj, JRecord):
36
+ rows = obj.to_rows()
37
+ if rows:
38
+ return rows[0]
39
+ return None
40
+
41
+
42
+ def _print_field(name: str, value: Any, *, width: int = 1000) -> None:
43
+ text = _shorten(value, width=width)
44
+ if "\n" not in text:
45
+ print(f"{name}: {text}")
46
+ return
47
+ print(f"{name}:")
48
+ print(textwrap.indent(text, " "))
49
+
50
+
51
+ def _print_jrow(row: JRow) -> None:
52
+ rubric = row.rubric.to_dict()
53
+ code_execution = rubric.pop("code_execution", None)
54
+
55
+ print("\nFirst JRow")
56
+ print("-" * 40)
57
+ _print_field("id", row.id)
58
+ _print_field("record_id", row.record_id)
59
+ _print_field("rubric_index", row.rubric_index)
60
+ _print_field("source", json.dumps(row.source.to_dict(), ensure_ascii=False))
61
+ _print_field("input", row.input)
62
+ _print_field("output", row.output)
63
+ _print_field("reference", row.reference)
64
+
65
+ print("\nRubric")
66
+ print("-" * 40)
67
+ for key, value in rubric.items():
68
+ if isinstance(value, dict):
69
+ value = json.dumps(value, ensure_ascii=False, indent=2)
70
+ _print_field(key, value)
71
+
72
+ if code_execution is not None:
73
+ print("\nCode Execution")
74
+ print("-" * 40)
75
+ if hasattr(code_execution, "to_dict"):
76
+ code_execution = code_execution.to_dict()
77
+ for key, value in code_execution.items():
78
+ _print_field(key, value)
79
+
80
+
81
+ def inspect(path: str) -> None:
82
+ """Print a brief summary and the first JRow in a parquet file."""
83
+ parquet_path = Path(path)
84
+ objects = load_parquet_objects(parquet_path)
85
+ print(f"path: {parquet_path}")
86
+ print(f"entries: {len(objects)}")
87
+
88
+ row = _first_jrow(objects)
89
+ if row is None:
90
+ print("\nNo JRow found in this file.")
91
+ return
92
+ _print_jrow(row)
93
+
94
+
95
+ def sample_rows(
96
+ input_path: str,
97
+ output_path: str,
98
+ seed: int = 55,
99
+ max_input_objects: int = 0,
100
+ max_outputs_per_record: int = 1,
101
+ max_rubrics_per_record: int = 2,
102
+ keep_empty_outputs: bool = False,
103
+ ) -> None:
104
+ """Sample JRows from preserved JRecordSet and JRecord parquet objects."""
105
+ stats = sample_jrows_file(
106
+ input_path,
107
+ output_path,
108
+ seed=seed,
109
+ max_input_objects=max_input_objects,
110
+ max_outputs_per_record=max_outputs_per_record,
111
+ max_rubrics_per_record=max_rubrics_per_record,
112
+ keep_empty_outputs=keep_empty_outputs,
113
+ )
114
+ print(json.dumps(stats, indent=2))
115
+
116
+
117
+ def sample_records(
118
+ input_path: str,
119
+ output_path: str,
120
+ seed: int = 55,
121
+ max_input_record_sets: int = 0,
122
+ max_outputs_per_record: int = 1,
123
+ selection: str = "random",
124
+ keep_empty_outputs: bool = False,
125
+ ) -> None:
126
+ """Sample single-output JRecords from preserved JRecordSet parquet objects."""
127
+ stats = sample_jrecords_file(
128
+ input_path,
129
+ output_path,
130
+ seed=seed,
131
+ max_input_record_sets=max_input_record_sets,
132
+ max_outputs_per_record=max_outputs_per_record,
133
+ selection=selection,
134
+ keep_empty_outputs=keep_empty_outputs,
135
+ )
136
+ print(json.dumps(stats, indent=2))
137
+
138
+
139
+ def main(argv: list[str] | None = None) -> None:
140
+ fire.Fire(
141
+ {
142
+ "inspect": inspect,
143
+ "sample-jrecords": sample_records,
144
+ "sample-jrows": sample_rows,
145
+ },
146
+ command=argv,
147
+ )
148
+
149
+
150
+ if __name__ == "__main__":
151
+ main()