@sedum-dev/provider-typesafe 0.1.0-alpha.22 → 0.1.0-alpha.23

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.
package/dist/index.d.ts CHANGED
@@ -132,12 +132,7 @@ declare class TypeSafeAdapter implements Resolver, Judge, TargetChecker, VisionR
132
132
  /** Bug-detector questions about one page state, answered in one call. */
133
133
  inspectPage(page: InspectedPage, options?: ProviderCallOptions): Promise<PageInspection>;
134
134
  /** Experimental test-impact scoring; one independent Noul per complete test. */
135
- scoreRelevance(diff: string, tests: readonly RelevanceTest[], options?: ProviderCallOptions): Promise<{
136
- probabilities: number[];
137
- calls: _sedum_dev_core.ProviderCall[];
138
- chunkCount: number;
139
- oversized: number[];
140
- }>;
135
+ scoreRelevance(diff: string, tests: readonly RelevanceTest[], options?: ProviderCallOptions): Promise<_sedum_dev_core.RelevanceScores>;
141
136
  classifyBatch(sentences: readonly string[], options?: ProviderCallOptions): Promise<{
142
137
  readonly answers: readonly ModelClassification[];
143
138
  readonly calls: readonly ReturnType<typeof validateCall>[];
package/dist/index.js CHANGED
@@ -3,7 +3,11 @@ import {
3
3
  TypeSafeClient as TypeSafeClient3,
4
4
  choice as choice6
5
5
  } from "@typesafe-ai/sdk";
6
- import { ClassificationBatchError, ProviderError as ProviderError8 } from "@sedum-dev/core";
6
+ import {
7
+ ClassificationBatchError,
8
+ ProviderError as ProviderError8,
9
+ scoreRelevancePlan
10
+ } from "@sedum-dev/core";
7
11
  import {
8
12
  MODEL_CHOICES
9
13
  } from "@sedum-dev/core";
@@ -503,7 +507,7 @@ function buildRelevanceRequests(diff, tests, model) {
503
507
  diff,
504
508
  tests,
505
509
  (text, questions) => ({ model, state: { diff: text }, questions }),
506
- { pair: 28e3, batch: 56e3, questions: Infinity, minDiff: 4096 }
510
+ { pair: 3e4, batch: 6e4, questions: Infinity, minDiff: 2e3 }
507
511
  );
508
512
  }
509
513
 
@@ -1592,45 +1596,36 @@ var TypeSafeAdapter = class {
1592
1596
  }
1593
1597
  /** Experimental test-impact scoring; one independent Noul per complete test. */
1594
1598
  async scoreRelevance(diff, tests, options) {
1595
- const { batches: chunks, oversized } = buildRelevanceRequests(
1596
- diff,
1597
- tests,
1598
- this.model
1599
- );
1600
- const probabilities = tests.map(() => 0);
1601
- const calls = [];
1602
- for (const { request, indexes } of chunks) {
1603
- const { response, meta } = await this.ask(request, options);
1604
- const call = validateCall(
1605
- response,
1606
- meta,
1607
- this.model,
1608
- this.estimateJevCost
1609
- );
1610
- calls.push(call);
1611
- try {
1612
- const answers = answersOf(response);
1613
- const keys = indexes.map((index) => `test${index}`);
1614
- validateAnswerKeys(
1615
- answers,
1616
- keys,
1617
- "Relevance answer keys do not match the tests."
1599
+ return scoreRelevancePlan(
1600
+ buildRelevanceRequests(diff, tests, this.model),
1601
+ tests.length,
1602
+ async (request, indexes) => {
1603
+ const { response, meta } = await this.ask(request, options);
1604
+ const call = validateCall(
1605
+ response,
1606
+ meta,
1607
+ this.model,
1608
+ this.estimateJevCost
1618
1609
  );
1619
- for (const index of indexes)
1620
- probabilities[index] = Math.max(
1621
- probabilities[index],
1622
- validateNoul(answers[`test${index}`])
1610
+ try {
1611
+ const answers = answersOf(response);
1612
+ validateAnswerKeys(
1613
+ answers,
1614
+ indexes.map((index) => `test${index}`),
1615
+ "Relevance answer keys do not match the tests."
1623
1616
  );
1624
- } catch (error) {
1625
- throw responseError(error, call.attempts, call);
1626
- }
1627
- }
1628
- return {
1629
- probabilities,
1630
- calls,
1631
- chunkCount: new Set(chunks.map((chunk) => chunk.chunkIndex)).size,
1632
- oversized
1633
- };
1617
+ return {
1618
+ call,
1619
+ scores: indexes.map(
1620
+ (index) => validateNoul(answers[`test${index}`])
1621
+ )
1622
+ };
1623
+ } catch (error) {
1624
+ throw responseError(error, call.attempts, call);
1625
+ }
1626
+ },
1627
+ options
1628
+ );
1634
1629
  }
1635
1630
  async classifyBatch(sentences, options) {
1636
1631
  const chunks = buildClassificationRequests(sentences, this.model);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sedum-dev/provider-typesafe",
3
- "version": "0.1.0-alpha.22",
3
+ "version": "0.1.0-alpha.23",
4
4
  "repository": "https://github.com/sedum-dev/sedum",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -20,7 +20,7 @@
20
20
  ],
21
21
  "dependencies": {
22
22
  "@typesafe-ai/sdk": "0.6.0",
23
- "@sedum-dev/core": "0.1.0-alpha.22"
23
+ "@sedum-dev/core": "0.1.0-alpha.23"
24
24
  },
25
25
  "scripts": {
26
26
  "build": "tsup src/index.ts --format esm --dts --clean --out-dir dist",