@budibase/pro 3.5.3 → 3.7.0

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.
@@ -1 +1 @@
1
- export { LargeLanguageModel } from "./LargeLanguageModel";
1
+ export { getLLM } from "./llm";
@@ -0,0 +1,2 @@
1
+ import { LLM } from "./models/base";
2
+ export declare function getLLM(model?: string): Promise<LLM | undefined>;
@@ -1,15 +1,11 @@
1
- import { ILargeLanguageModel, LLMPromptResponse } from "../../types/ai";
1
+ import AnthropicClient from "@anthropic-ai/sdk";
2
+ import { LLMPromptResponse } from "../../types/ai";
3
+ import { AIConfigOptions, LLM } from "./base";
4
+ import { Prompt } from "../prompts";
2
5
  export type AnthropicModel = "claude-3-5-sonnet-20240620" | "claude-3-sonnet-20240229" | "claude-3-opus-20240229" | "claude-3-haiku-20240307";
3
- export interface AnthropicConfigOptions {
4
- model: AnthropicModel;
5
- apiKey: string;
6
- measureUsage?: boolean;
7
- }
8
- export declare class Anthropic implements ILargeLanguageModel {
6
+ export declare class Anthropic extends LLM {
9
7
  private client;
10
- model: string;
11
- constructor({ model, apiKey }: AnthropicConfigOptions);
12
- chatCompletion(prompt: string): Promise<LLMPromptResponse>;
13
- prompt(prompt: string): Promise<LLMPromptResponse>;
14
- summarizeText(prompt: string): Promise<LLMPromptResponse>;
8
+ constructor(opts: AIConfigOptions);
9
+ firstTextBlock(message: AnthropicClient.Messages.Message): string | undefined;
10
+ protected chatCompletion(prompt: Prompt): Promise<LLMPromptResponse>;
15
11
  }
@@ -0,0 +1,25 @@
1
+ import { AIFieldMetadata, EnrichedBinding, Row, Snippet } from "@budibase/types";
2
+ import { LLMPromptResponse } from "../../types/ai";
3
+ import { Prompt } from "../prompts";
4
+ export interface AIConfigOptions {
5
+ model: string;
6
+ apiKey: string;
7
+ measureUsage: boolean;
8
+ }
9
+ export declare abstract class LLM {
10
+ model: string;
11
+ apiKey: string;
12
+ measureUsage: boolean;
13
+ maxTokens: number;
14
+ constructor({ model, apiKey, measureUsage }: AIConfigOptions);
15
+ protected abstract chatCompletion(prompt: Prompt): Promise<LLMPromptResponse>;
16
+ prompt(prompt: string | Prompt): Promise<LLMPromptResponse>;
17
+ summarizeText(prompt: string): Promise<LLMPromptResponse>;
18
+ generateCronExpression(prompt: string): Promise<LLMPromptResponse>;
19
+ operation(schema: AIFieldMetadata, row: Row): Promise<LLMPromptResponse>;
20
+ private promptForOperation;
21
+ generateJs(prompt: string, opts?: {
22
+ bindings: EnrichedBinding[];
23
+ snippets: Snippet[];
24
+ }): Promise<LLMPromptResponse>;
25
+ }
@@ -1,18 +1,11 @@
1
1
  import OpenAIClient from "openai";
2
- import { ILargeLanguageModel, LLMPromptResponse } from "../../types/ai";
2
+ import { LLMPromptResponse } from "../../types/ai";
3
+ import { AIConfigOptions, LLM } from "./base";
4
+ import { Prompt } from "../prompts";
3
5
  export type OpenAIModel = "gpt-4o-mini" | "gpt-4o" | "gpt-4" | "gpt-4-turbo" | "gpt-3.5-turbo";
4
- export interface OpenAIConfigOptions {
5
- model: OpenAIModel;
6
- apiKey: string;
7
- measureUsage: boolean;
8
- }
9
- export declare class OpenAI implements ILargeLanguageModel {
6
+ export declare class OpenAI extends LLM {
10
7
  private client;
11
- model: string;
12
- measureUsage: boolean;
13
- constructor({ model, apiKey, measureUsage }: OpenAIConfigOptions);
8
+ constructor({ model, apiKey, measureUsage }: AIConfigOptions);
14
9
  measureTokenUsage(usage?: OpenAIClient.CompletionUsage): number;
15
- chatCompletion(prompt: string): Promise<LLMPromptResponse>;
16
- prompt(prompt: string): Promise<LLMPromptResponse>;
17
- summarizeText(prompt: string): Promise<LLMPromptResponse>;
10
+ protected chatCompletion(prompt: Prompt): Promise<LLMPromptResponse>;
18
11
  }
@@ -1,9 +1,23 @@
1
- export declare function summarizeText(text: string): string;
2
- export declare function classifyText(text: string, categories: string[]): string;
3
- export declare function cleanData(text: string): string;
4
- export declare function generateSQL(prompt: string, tableSchema: string): string;
5
- export declare function generateCode(prompt: string): string;
6
- export declare function generateCronExpression(text: string): string;
7
- export declare function translate(text: string, language: string): string;
8
- export declare function sentimentAnalysis(text: string): string;
9
- export declare function searchWeb(text: string): string;
1
+ import { EnrichedBinding, Snippet } from "@budibase/types";
2
+ export interface Message {
3
+ role: "system" | "user";
4
+ content: string;
5
+ }
6
+ export declare class Prompt {
7
+ messages: Message[];
8
+ constructor(messages: Message[]);
9
+ user(content: string): this;
10
+ system(content: string): this;
11
+ static user(content: string): Prompt;
12
+ static system(content: string): Prompt;
13
+ }
14
+ export declare function summarizeText(text: string): Prompt;
15
+ export declare function classifyText(text: string, categories: string[]): Prompt;
16
+ export declare function cleanData(text: string): Prompt;
17
+ export declare function generateSQL(prompt: string, tableSchema: string): Prompt;
18
+ export declare function generateCode(prompt: string): Prompt;
19
+ export declare function generateCronExpression(text: string): Prompt;
20
+ export declare function translate(text: string, language: string): Prompt;
21
+ export declare function sentimentAnalysis(text: string): Prompt;
22
+ export declare function searchWeb(text: string): Prompt;
23
+ export declare function generateJs(bindings: EnrichedBinding[], snippets: Snippet[]): Prompt;
@@ -16,6 +16,7 @@ interface SetAllUsageParams {
16
16
  opts?: {
17
17
  id?: string;
18
18
  appId?: string;
19
+ tenantId?: string;
19
20
  };
20
21
  }
21
22
  export declare const setAllUsage: (params: SetAllUsageParams | SetAllUsageParams[]) => Promise<QuotaUsage>;