From ff7b3e222de99236e03c699f7edc61f56e0ed06f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 1 Feb 2025 00:27:31 +0000 Subject: [PATCH] feat(api): api update --- .stats.yml | 2 +- api.md | 4 +-- src/index.ts | 4 +-- src/resources/documents.ts | 70 +++++++++++++++++++++++--------------- src/resources/index.ts | 2 +- src/resources/query.ts | 39 +++++++++++++++------ 6 files changed, 78 insertions(+), 43 deletions(-) diff --git a/.stats.yml b/.stats.yml index 53de1033..46b24875 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 2 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hyperspell%2Fhyperspell-de985d11041334568361f7cc095daa97f14f1808d7ce817b3186b1e9b912ac3c.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hyperspell%2Fhyperspell-b96e3394276a930bfc20b33900bda9ba5bed9d12ba4eaf3849b555f2b11131de.yml diff --git a/api.md b/api.md index 43e9819d..6153462e 100644 --- a/api.md +++ b/api.md @@ -14,8 +14,8 @@ Methods: Types: -- Document +- DocumentRetrieveResponse Methods: -- client.documents.retrieve(documentId) -> Document +- client.documents.retrieve(documentId) -> DocumentRetrieveResponse diff --git a/src/index.ts b/src/index.ts index a6640ee6..c18790db 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,7 @@ import * as Core from './core'; import * as Errors from './error'; import * as Uploads from './uploads'; import * as API from './resources/index'; -import { Document, Documents } from './resources/documents'; +import { DocumentRetrieveResponse, Documents } from './resources/documents'; import { Ingest } from './resources/ingest'; import { Query, QueryRetrieveParams, QueryRetrieveResponse } from './resources/query'; @@ -176,7 +176,7 @@ export declare namespace Hyperspell { type QueryRetrieveParams as QueryRetrieveParams, }; - export { Documents as Documents, type Document as Document }; + export { Documents as Documents, type DocumentRetrieveResponse as DocumentRetrieveResponse }; } export { toFile, fileFromPath } from './uploads'; diff --git a/src/resources/documents.ts b/src/resources/documents.ts index 677b8798..8e3bfa75 100644 --- a/src/resources/documents.ts +++ b/src/resources/documents.ts @@ -5,32 +5,31 @@ import * as Core from '../core'; export class Documents extends APIResource { /** - * Retrieves a document by ID. + * Retrieves a document by ID, including its collection name and sections. */ - retrieve(documentId: number, options?: Core.RequestOptions): Core.APIPromise { + retrieve(documentId: number, options?: Core.RequestOptions): Core.APIPromise { return this._client.get(`/documents/get/${documentId}`, options); } } -export interface Document { - collection_id: number; +export interface DocumentRetrieveResponse { + id: number | null; - id?: number | null; + collection: string; - created_at?: string | null; + created_at: string | null; - ingested_at?: string | null; + ingested_at: string | null; - metadata?: unknown; + metadata: unknown; - /** - * Along with service, uniquely identifies the source document - */ - resource_id?: string; + resource_id: string; - sections?: Array; + title: string | null; - sections_count?: number | null; + sections?: Array< + DocumentRetrieveResponse.SectionResult | DocumentRetrieveResponse.SectionResultWithElements + >; source?: | 'generic' @@ -50,30 +49,47 @@ export interface Document { | 'google_docs'; status?: 'pending' | 'processing' | 'completed' | 'failed'; - - title?: string | null; } -export namespace Document { - export interface Section { - document_id: number; - +export namespace DocumentRetrieveResponse { + export interface SectionResult { id?: number | null; - elements?: Array; + scores?: SectionResult.Scores; - embedding_e5_large?: Array | null; + text?: string; + } - embedding_ts?: string | null; + export namespace SectionResult { + export interface Scores { + /** + * How relevant the section is based on full text search + */ + full_text_search?: number | null; + + /** + * How relevant the section is based on vector search + */ + semantic_search?: number | null; + + /** + * The final weighted score of the section + */ + weighted?: number | null; + } + } + + export interface SectionResultWithElements { + id?: number | null; - metadata?: unknown; + elements?: Array; - scores?: Section.Scores; + scores?: SectionResultWithElements.Scores; text?: string; } - export namespace Section { + export namespace SectionResultWithElements { export interface Element { text: string; @@ -128,5 +144,5 @@ export namespace Document { } export declare namespace Documents { - export { type Document as Document }; + export { type DocumentRetrieveResponse as DocumentRetrieveResponse }; } diff --git a/src/resources/index.ts b/src/resources/index.ts index f8086ff2..c7abc08b 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -1,5 +1,5 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { Documents, type Document } from './documents'; +export { Documents, type DocumentRetrieveResponse } from './documents'; export { Ingest } from './ingest'; export { Query, type QueryRetrieveResponse, type QueryRetrieveParams } from './query'; diff --git a/src/resources/query.ts b/src/resources/query.ts index ff2d8c97..0f560f9c 100644 --- a/src/resources/query.ts +++ b/src/resources/query.ts @@ -34,7 +34,7 @@ export namespace QueryRetrieveResponse { title: string | null; - sections?: Array; + sections?: Array; source?: | 'generic' @@ -57,25 +57,44 @@ export namespace QueryRetrieveResponse { } export namespace Document { - export interface Section { - document_id: number; - + export interface SectionResult { id?: number | null; - elements?: Array; + scores?: SectionResult.Scores; + + text?: string; + } + + export namespace SectionResult { + export interface Scores { + /** + * How relevant the section is based on full text search + */ + full_text_search?: number | null; + + /** + * How relevant the section is based on vector search + */ + semantic_search?: number | null; - embedding_e5_large?: Array | null; + /** + * The final weighted score of the section + */ + weighted?: number | null; + } + } - embedding_ts?: string | null; + export interface SectionResultWithElements { + id?: number | null; - metadata?: unknown; + elements?: Array; - scores?: Section.Scores; + scores?: SectionResultWithElements.Scores; text?: string; } - export namespace Section { + export namespace SectionResultWithElements { export interface Element { text: string;