grader-models.d.ts 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. import { APIResource } from "../../resource.js";
  2. import * as ResponsesAPI from "../responses/responses.js";
  3. export declare class GraderModels extends APIResource {
  4. }
  5. /**
  6. * A LabelModelGrader object which uses a model to assign labels to each item in
  7. * the evaluation.
  8. */
  9. export interface LabelModelGrader {
  10. input: Array<LabelModelGrader.Input>;
  11. /**
  12. * The labels to assign to each item in the evaluation.
  13. */
  14. labels: Array<string>;
  15. /**
  16. * The model to use for the evaluation. Must support structured outputs.
  17. */
  18. model: string;
  19. /**
  20. * The name of the grader.
  21. */
  22. name: string;
  23. /**
  24. * The labels that indicate a passing result. Must be a subset of labels.
  25. */
  26. passing_labels: Array<string>;
  27. /**
  28. * The object type, which is always `label_model`.
  29. */
  30. type: 'label_model';
  31. }
  32. export declare namespace LabelModelGrader {
  33. /**
  34. * A message input to the model with a role indicating instruction following
  35. * hierarchy. Instructions given with the `developer` or `system` role take
  36. * precedence over instructions given with the `user` role. Messages with the
  37. * `assistant` role are presumed to have been generated by the model in previous
  38. * interactions.
  39. */
  40. interface Input {
  41. /**
  42. * Text inputs to the model - can contain template strings.
  43. */
  44. content: string | ResponsesAPI.ResponseInputText | Input.OutputText;
  45. /**
  46. * The role of the message input. One of `user`, `assistant`, `system`, or
  47. * `developer`.
  48. */
  49. role: 'user' | 'assistant' | 'system' | 'developer';
  50. /**
  51. * The type of the message input. Always `message`.
  52. */
  53. type?: 'message';
  54. }
  55. namespace Input {
  56. /**
  57. * A text output from the model.
  58. */
  59. interface OutputText {
  60. /**
  61. * The text output from the model.
  62. */
  63. text: string;
  64. /**
  65. * The type of the output text. Always `output_text`.
  66. */
  67. type: 'output_text';
  68. }
  69. }
  70. }
  71. /**
  72. * A MultiGrader object combines the output of multiple graders to produce a single
  73. * score.
  74. */
  75. export interface MultiGrader {
  76. /**
  77. * A formula to calculate the output based on grader results.
  78. */
  79. calculate_output: string;
  80. graders: Record<string, StringCheckGrader | TextSimilarityGrader | PythonGrader | ScoreModelGrader | LabelModelGrader>;
  81. /**
  82. * The name of the grader.
  83. */
  84. name: string;
  85. /**
  86. * The object type, which is always `multi`.
  87. */
  88. type: 'multi';
  89. }
  90. /**
  91. * A PythonGrader object that runs a python script on the input.
  92. */
  93. export interface PythonGrader {
  94. /**
  95. * The name of the grader.
  96. */
  97. name: string;
  98. /**
  99. * The source code of the python script.
  100. */
  101. source: string;
  102. /**
  103. * The object type, which is always `python`.
  104. */
  105. type: 'python';
  106. /**
  107. * The image tag to use for the python script.
  108. */
  109. image_tag?: string;
  110. }
  111. /**
  112. * A ScoreModelGrader object that uses a model to assign a score to the input.
  113. */
  114. export interface ScoreModelGrader {
  115. /**
  116. * The input text. This may include template strings.
  117. */
  118. input: Array<ScoreModelGrader.Input>;
  119. /**
  120. * The model to use for the evaluation.
  121. */
  122. model: string;
  123. /**
  124. * The name of the grader.
  125. */
  126. name: string;
  127. /**
  128. * The object type, which is always `score_model`.
  129. */
  130. type: 'score_model';
  131. /**
  132. * The range of the score. Defaults to `[0, 1]`.
  133. */
  134. range?: Array<number>;
  135. /**
  136. * The sampling parameters for the model.
  137. */
  138. sampling_params?: unknown;
  139. }
  140. export declare namespace ScoreModelGrader {
  141. /**
  142. * A message input to the model with a role indicating instruction following
  143. * hierarchy. Instructions given with the `developer` or `system` role take
  144. * precedence over instructions given with the `user` role. Messages with the
  145. * `assistant` role are presumed to have been generated by the model in previous
  146. * interactions.
  147. */
  148. interface Input {
  149. /**
  150. * Text inputs to the model - can contain template strings.
  151. */
  152. content: string | ResponsesAPI.ResponseInputText | Input.OutputText;
  153. /**
  154. * The role of the message input. One of `user`, `assistant`, `system`, or
  155. * `developer`.
  156. */
  157. role: 'user' | 'assistant' | 'system' | 'developer';
  158. /**
  159. * The type of the message input. Always `message`.
  160. */
  161. type?: 'message';
  162. }
  163. namespace Input {
  164. /**
  165. * A text output from the model.
  166. */
  167. interface OutputText {
  168. /**
  169. * The text output from the model.
  170. */
  171. text: string;
  172. /**
  173. * The type of the output text. Always `output_text`.
  174. */
  175. type: 'output_text';
  176. }
  177. }
  178. }
  179. /**
  180. * A StringCheckGrader object that performs a string comparison between input and
  181. * reference using a specified operation.
  182. */
  183. export interface StringCheckGrader {
  184. /**
  185. * The input text. This may include template strings.
  186. */
  187. input: string;
  188. /**
  189. * The name of the grader.
  190. */
  191. name: string;
  192. /**
  193. * The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`.
  194. */
  195. operation: 'eq' | 'ne' | 'like' | 'ilike';
  196. /**
  197. * The reference text. This may include template strings.
  198. */
  199. reference: string;
  200. /**
  201. * The object type, which is always `string_check`.
  202. */
  203. type: 'string_check';
  204. }
  205. /**
  206. * A TextSimilarityGrader object which grades text based on similarity metrics.
  207. */
  208. export interface TextSimilarityGrader {
  209. /**
  210. * The evaluation metric to use. One of `fuzzy_match`, `bleu`, `gleu`, `meteor`,
  211. * `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, `rouge_5`, or `rouge_l`.
  212. */
  213. evaluation_metric: 'fuzzy_match' | 'bleu' | 'gleu' | 'meteor' | 'rouge_1' | 'rouge_2' | 'rouge_3' | 'rouge_4' | 'rouge_5' | 'rouge_l';
  214. /**
  215. * The text being graded.
  216. */
  217. input: string;
  218. /**
  219. * The name of the grader.
  220. */
  221. name: string;
  222. /**
  223. * The text being graded against.
  224. */
  225. reference: string;
  226. /**
  227. * The type of grader.
  228. */
  229. type: 'text_similarity';
  230. }
  231. export declare namespace GraderModels {
  232. export { type LabelModelGrader as LabelModelGrader, type MultiGrader as MultiGrader, type PythonGrader as PythonGrader, type ScoreModelGrader as ScoreModelGrader, type StringCheckGrader as StringCheckGrader, type TextSimilarityGrader as TextSimilarityGrader, };
  233. }
  234. //# sourceMappingURL=grader-models.d.ts.map