diff --git a/README.md b/README.md index d5cbf5c..7958c97 100644 --- a/README.md +++ b/README.md @@ -205,6 +205,15 @@ console.log(response.document_chunks) ## Repositories Repositories act as storage for documents, organized to facilitate efficient information retrieval. Manipulating repository content is straightforward. +### Repository creation +To create a repository, you can use the `create` method provided by the `repositories` API. Here's an example of how to create a repository: +```typescript +const response = await client.repositories.create({ + name: "Test", + description: "Test Repository", + organization: "org-test@premai.io" +}) +``` ### Document creation To add a document to a repository, you can use the `create` method provided by the `document` API. Here's an example of how to create and upload a document: diff --git a/package.json b/package.json index a0d4402..132ba01 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@premai/prem-sdk", - "version": "0.3.55", + "version": "0.3.56", "license": "MIT", "main": "./dist/index.js", "module": "./dist/index.mjs", diff --git a/src/index.ts b/src/index.ts index 649fe33..b68de48 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,6 +4,7 @@ import { PremBaseConfig } from "$types/index" import chatcompletionsModule from "$modules/chat.completions" import embeddingsModule from "$modules/embeddings" import modelsModule from "$modules/models" +import repositoriesModule from "$modules/repositories" import repositorydocumentModule from "$modules/repository.document" import feedbacksModule from "$modules/feedbacks" import tracesModule from "$modules/traces" @@ -15,6 +16,7 @@ export default class Prem { chat = { completions: new chatcompletionsModule(this) } embeddings = new embeddingsModule(this) models = new modelsModule(this) + repositories = new repositoriesModule(this) repository = { document: new repositorydocumentModule(this) } feedbacks = new feedbacksModule(this) traces = new tracesModule(this) diff --git a/src/modules/repositories/index.ts b/src/modules/repositories/index.ts new file mode 100644 index 0000000..a0ed04d --- /dev/null +++ b/src/modules/repositories/index.ts @@ -0,0 +1,7 @@ +import { APIModule } from "$components/index" + +import v1_repositories_create from "./operations/v1_repositories_create" + +export default class extends APIModule { + create = v1_repositories_create(this.client) +} \ No newline at end of file diff --git a/src/modules/repositories/operations/v1_repositories_create.ts b/src/modules/repositories/operations/v1_repositories_create.ts new file mode 100644 index 0000000..147de99 --- /dev/null +++ b/src/modules/repositories/operations/v1_repositories_create.ts @@ -0,0 +1,12 @@ +import { AxiosRequestConfig } from "axios" +import Prem from "$src/index" +import type { operations } from "$types/api" + +export default (client: Prem) => (params: operations["v1_repositories_create"]["requestBody"]["content"]["application/json"], options?: AxiosRequestConfig): Promise => { + return client.call({ + method: "post", + url: `/v1/repositories/`, + data: params, + ...options + }) +} \ No newline at end of file diff --git a/src/types/api.d.ts b/src/types/api.d.ts index 621bbb0..cb3ff37 100644 --- a/src/types/api.d.ts +++ b/src/types/api.d.ts @@ -24,6 +24,9 @@ export interface paths { "/v1/models/{id}/": { get: operations["v1_models_retrieve"]; }; + "/v1/repositories/": { + post: operations["v1_repositories_create"]; + }; "/v1/repository/{repository_id}/document": { post: operations["v1_repository_document_create"]; }; @@ -426,9 +429,10 @@ export interface components { * @description * `text2text` - Text to Text * * `text2image` - Text to Image * * `text2vector` - Text to Vector + * * `autopilot` - Autopilot * @enum {string} */ - model_type?: "text2text" | "text2image" | "text2vector"; + model_type?: "text2text" | "text2image" | "text2vector" | "autopilot"; model_provider?: ("openai" | "azure" | "azure-mistral" | "cohere" | "anthropic" | "cloudflare" | "deepinfra" | "lamini" | "octoai" | "replicate" | "together" | "fireworksai" | "mistralai" | "prem" | "anyscale" | "openrouter" | "perplexity" | "groq") | "" | null; deprecated?: boolean; }; @@ -471,9 +475,10 @@ export interface components { * @description * `text2text` - Text to Text * * `text2image` - Text to Image * * `text2vector` - Text to Vector + * * `autopilot` - Autopilot * @enum {string} */ - ModelTypeEnum: "text2text" | "text2image" | "text2vector"; + ModelTypeEnum: "text2text" | "text2image" | "text2vector" | "autopilot"; NotFoundError: OneOf<[{ message: string; /** @@ -588,6 +593,12 @@ export interface components { * @enum {string} */ RateLimitErrorCodeEnum: "RateLimitError"; + Repository: { + id: number; + name: string; + description?: string | null; + organization: string; + }; ResponseChoice: { /** @description The index of the choice in the list of choices. */ index: number; @@ -677,9 +688,10 @@ export interface components { * @description * `text2text` - Text to Text * * `text2image` - Text to Image * * `text2vector` - Text to Vector + * * `autopilot` - Autopilot * @enum {string} */ - model_type?: "text2text" | "text2image" | "text2vector"; + model_type?: "text2text" | "text2image" | "text2vector" | "autopilot"; model_provider?: ("openai" | "azure" | "azure-mistral" | "cohere" | "anthropic" | "cloudflare" | "deepinfra" | "lamini" | "octoai" | "replicate" | "together" | "fireworksai" | "mistralai" | "prem" | "anyscale" | "openrouter" | "perplexity" | "groq") | "" | null; deprecated?: boolean; }; @@ -1367,9 +1379,10 @@ export interface operations { * @description * `text2text` - Text to Text * * `text2image` - Text to Image * * `text2vector` - Text to Vector + * * `autopilot` - Autopilot * @enum {string} */ - model_type?: "text2text" | "text2image" | "text2vector"; + model_type?: "text2text" | "text2image" | "text2vector" | "autopilot"; model_provider?: ("openai" | "azure" | "azure-mistral" | "cohere" | "anthropic" | "cloudflare" | "deepinfra" | "lamini" | "octoai" | "replicate" | "together" | "fireworksai" | "mistralai" | "prem" | "anyscale" | "openrouter" | "perplexity" | "groq") | "" | null; deprecated?: boolean; })[]; @@ -1394,9 +1407,10 @@ export interface operations { * @description * `text2text` - Text to Text * * `text2image` - Text to Image * * `text2vector` - Text to Vector + * * `autopilot` - Autopilot * @enum {string} */ - model_type?: "text2text" | "text2image" | "text2vector"; + model_type?: "text2text" | "text2image" | "text2vector" | "autopilot"; model_provider?: ("openai" | "azure" | "azure-mistral" | "cohere" | "anthropic" | "cloudflare" | "deepinfra" | "lamini" | "octoai" | "replicate" | "together" | "fireworksai" | "mistralai" | "prem" | "anyscale" | "openrouter" | "perplexity" | "groq") | "" | null; deprecated?: boolean; }; @@ -1404,6 +1418,42 @@ export interface operations { }; }; }; + v1_repositories_create: { + requestBody: { + content: { + "application/json": { + id: number; + name: string; + description?: string | null; + organization: string; + }; + "application/x-www-form-urlencoded": { + id: number; + name: string; + description?: string | null; + organization: string; + }; + "multipart/form-data": { + id: number; + name: string; + description?: string | null; + organization: string; + }; + }; + }; + responses: { + 201: { + content: { + "application/json": { + id: number; + name: string; + description?: string | null; + organization: string; + }; + }; + }; + }; + }; v1_repository_document_create: { parameters: { path: { @@ -1596,9 +1646,10 @@ export interface operations { * @description * `text2text` - Text to Text * * `text2image` - Text to Image * * `text2vector` - Text to Vector + * * `autopilot` - Autopilot * @enum {string} */ - model_type?: "text2text" | "text2image" | "text2vector"; + model_type?: "text2text" | "text2image" | "text2vector" | "autopilot"; model_provider?: ("openai" | "azure" | "azure-mistral" | "cohere" | "anthropic" | "cloudflare" | "deepinfra" | "lamini" | "octoai" | "replicate" | "together" | "fireworksai" | "mistralai" | "prem" | "anyscale" | "openrouter" | "perplexity" | "groq") | "" | null; deprecated?: boolean; }; diff --git a/src/types/apiComponents.d.ts b/src/types/apiComponents.d.ts index 2c9c202..a63d8fe 100644 --- a/src/types/apiComponents.d.ts +++ b/src/types/apiComponents.d.ts @@ -500,8 +500,9 @@ export type Model = { * * `text2text` - Text to Text * * `text2image` - Text to Image * * `text2vector` - Text to Vector + * * `autopilot` - Autopilot */ - model_type?: "text2text" | "text2image" | "text2vector" + model_type?: "text2text" | "text2image" | "text2vector" | "autopilot" model_provider?: | ( | "openai" @@ -587,8 +588,9 @@ export type ModelProviderEnum = * * `text2text` - Text to Text * * `text2image` - Text to Image * * `text2vector` - Text to Vector + * * `autopilot` - Autopilot */ -export type ModelTypeEnum = "text2text" | "text2image" | "text2vector" +export type ModelTypeEnum = "text2text" | "text2image" | "text2vector" | "autopilot" export type NotFoundError = | { @@ -717,6 +719,14 @@ export type RateLimitError = { */ export type RateLimitErrorCodeEnum = "RateLimitError" +export type Repository = { + id: number + name: string + description?: string + organization: string + [k: string]: unknown +} + export type ResponseChoice = { /** * The index of the choice in the list of choices. @@ -832,8 +842,9 @@ export type TraceRetrieve = { * * `text2text` - Text to Text * * `text2image` - Text to Image * * `text2vector` - Text to Vector + * * `autopilot` - Autopilot */ - model_type?: "text2text" | "text2image" | "text2vector" + model_type?: "text2text" | "text2image" | "text2vector" | "autopilot" model_provider?: | ( | "openai"