@sedum-dev/provider-typesafe 0.1.0-alpha.21 → 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,11 +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
- }>;
135
+ scoreRelevance(diff: string, tests: readonly RelevanceTest[], options?: ProviderCallOptions): Promise<_sedum_dev_core.RelevanceScores>;
140
136
  classifyBatch(sentences: readonly string[], options?: ProviderCallOptions): Promise<{
141
137
  readonly answers: readonly ModelClassification[];
142
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 }
510
+ { pair: 3e4, batch: 6e4, questions: Infinity, minDiff: 2e3 }
507
511
  );
508
512
  }
509
513
 
@@ -1592,40 +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 chunks = buildRelevanceRequests(diff, tests, this.model);
1596
- const probabilities = tests.map(() => 0);
1597
- const calls = [];
1598
- for (const { request, indexes } of chunks) {
1599
- const { response, meta } = await this.ask(request, options);
1600
- const call = validateCall(
1601
- response,
1602
- meta,
1603
- this.model,
1604
- this.estimateJevCost
1605
- );
1606
- calls.push(call);
1607
- try {
1608
- const answers = answersOf(response);
1609
- const keys = indexes.map((index) => `test${index}`);
1610
- validateAnswerKeys(
1611
- answers,
1612
- keys,
1613
- "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
1614
1609
  );
1615
- for (const index of indexes)
1616
- probabilities[index] = Math.max(
1617
- probabilities[index],
1618
- 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."
1619
1616
  );
1620
- } catch (error) {
1621
- throw responseError(error, call.attempts, call);
1622
- }
1623
- }
1624
- return {
1625
- probabilities,
1626
- calls,
1627
- chunkCount: new Set(chunks.map((chunk) => chunk.chunkIndex)).size
1628
- };
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
+ );
1629
1629
  }
1630
1630
  async classifyBatch(sentences, options) {
1631
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.21",
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.21"
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",