You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@google-labs/palm-lite

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-labs/palm-lite - npm Package Compare versions

Comparing version

to
0.0.3

4

dist/src/chat.d.ts

@@ -24,3 +24,3 @@ /**

* chat.addMessage("Hello there!");
* const data = await fetch(palm(API_KEY).message(chat));
* const data = await fetch(palm(PALM_KEY).message(chat));
* const response = await data.json();

@@ -46,3 +46,3 @@ * ```

* });
* const data = await fetch(palm(API_KEY).message(chat));
* const data = await fetch(palm(PALM_KEY).message(chat));
* const response = await data.json();

@@ -49,0 +49,0 @@ * ```

@@ -16,3 +16,3 @@ /**

* chat.addMessage("Hello there!");
* const data = await fetch(palm(API_KEY).message(chat));
* const data = await fetch(palm(PALM_KEY).message(chat));
* const response = await data.json();

@@ -38,3 +38,3 @@ * ```

* });
* const data = await fetch(palm(API_KEY).message(chat));
* const data = await fetch(palm(PALM_KEY).message(chat));
* const response = await data.json();

@@ -41,0 +41,0 @@ * ```

@@ -8,5 +8,10 @@ /**

type PalmApiKey = string;
export declare enum PalmModelMethod {
GenerateMessage = "generateMessage",
GenerateText = "generateText",
EmbedText = "embedText"
}
declare class PaLM {
private key;
constructor(API_KEY: PalmApiKey);
constructor(PALM_KEY: PalmApiKey);
/**

@@ -33,2 +38,8 @@ * Produces the `Request` object for the PaLM API `generateMessage` method. The produced object can be supplied directly to `fetch` method.

embedding(request: EmbedTextRequest, model?: string): Request;
/**
* Returns the id, including name and version, of the model used.
* @param method PaLM API method, from @enum ModelMethod.
* @returns a string representing the model id.
*/
getModelId(method: PalmModelMethod): string;
}

@@ -40,5 +51,5 @@ /**

*
* // Make sure to set the API_KEY environment variable.
* const API_KEY = process.env.API_KEY;
* const request = palm(API_KEY).message({
* // Make sure to set the PALM_KEY environment variable.
* const PALM_KEY = process.env.PALM_KEY;
* const request = palm(PALM_KEY).message({
* prompt: {

@@ -45,0 +56,0 @@ * messages: [ { content: "Hello there!" } ],

@@ -8,5 +8,14 @@ /**

const ENDPOINT_URL = "https://generativelanguage.googleapis.com/v1beta2/models";
export var PalmModelMethod;
(function (PalmModelMethod) {
PalmModelMethod["GenerateMessage"] = "generateMessage";
PalmModelMethod["GenerateText"] = "generateText";
PalmModelMethod["EmbedText"] = "embedText";
})(PalmModelMethod || (PalmModelMethod = {}));
const getModelId = (method) => {
return models[method][0].name;
};
const prepareRequest = (key, method, request, model) => {
if (!model)
model = models[method][0].name;
model = getModelId(method);
const url = `${ENDPOINT_URL}/${model}:${method}?key=${key}`;

@@ -23,4 +32,4 @@ return new Request(url, {

key;
constructor(API_KEY) {
this.key = API_KEY;
constructor(PALM_KEY) {
this.key = PALM_KEY;
}

@@ -54,2 +63,10 @@ /**

}
/**
* Returns the id, including name and version, of the model used.
* @param method PaLM API method, from @enum ModelMethod.
* @returns a string representing the model id.
*/
getModelId(method) {
return getModelId(method);
}
}

@@ -61,5 +78,5 @@ /**

*
* // Make sure to set the API_KEY environment variable.
* const API_KEY = process.env.API_KEY;
* const request = palm(API_KEY).message({
* // Make sure to set the PALM_KEY environment variable.
* const PALM_KEY = process.env.PALM_KEY;
* const request = palm(PALM_KEY).message({
* prompt: {

@@ -66,0 +83,0 @@ * messages: [ { content: "Hello there!" } ],

/**
* This file was generated by scripts/make-models.js on 2023-06-14T18:18:10.946Z
* Do not edit this file manually.
*/
* This file was generated by scripts/make-models.js on 2023-06-14T18:18:10.946Z
* Do not edit this file manually.
*/
export declare const models: {

@@ -6,0 +6,0 @@ generateMessage: {

/**
* This file was generated by scripts/make-models.js on 2023-06-14T18:18:10.946Z
* Do not edit this file manually.
*/
* This file was generated by scripts/make-models.js on 2023-06-14T18:18:10.946Z
* Do not edit this file manually.
*/
export const models = {
"generateMessage": [
generateMessage: [
{
"name": "chat-bison-001",
"version": "001",
"displayName": "Chat Bison",
"description": "Chat-optimized generative language model.",
"inputTokenLimit": 4096,
"outputTokenLimit": 1024,
"temperature": 0.25,
"topP": 0.95,
"topK": 40
}
name: "chat-bison-001",
version: "001",
displayName: "Chat Bison",
description: "Chat-optimized generative language model.",
inputTokenLimit: 4096,
outputTokenLimit: 1024,
temperature: 0.25,
topP: 0.95,
topK: 40,
},
],
"generateText": [
generateText: [
{
"name": "text-bison-001",
"version": "001",
"displayName": "Text Bison",
"description": "Model targeted for text generation.",
"inputTokenLimit": 8196,
"outputTokenLimit": 1024,
"temperature": 0.7,
"topP": 0.95,
"topK": 40
}
name: "text-bison-001",
version: "001",
displayName: "Text Bison",
description: "Model targeted for text generation.",
inputTokenLimit: 8196,
outputTokenLimit: 1024,
temperature: 0.7,
topP: 0.95,
topK: 40,
},
],
"embedText": [
embedText: [
{
"name": "embedding-gecko-001",
"version": "001",
"displayName": "Embedding Gecko",
"description": "Obtain a distributed representation of a text.",
"inputTokenLimit": 1024,
"outputTokenLimit": 1
}
]
name: "embedding-gecko-001",
version: "001",
displayName: "Embedding Gecko",
description: "Obtain a distributed representation of a text.",
inputTokenLimit: 1024,
outputTokenLimit: 1,
},
],
};
//# sourceMappingURL=models.js.map

@@ -33,3 +33,3 @@ /**

* text.text("Hello there!");
* const data = await fetch(palm(API_KEY).text(text));
* const data = await fetch(palm(PALM_KEY).text(text));
* const response = await data.json();

@@ -56,3 +56,3 @@ * ```

* .addStopSequence("==");
* const data = await fetch(palm(API_KEY).text(text));
* const data = await fetch(palm(PALM_KEY).text(text));
* const response = await data.json();

@@ -59,0 +59,0 @@ * ```

@@ -20,3 +20,3 @@ /**

* text.text("Hello there!");
* const data = await fetch(palm(API_KEY).text(text));
* const data = await fetch(palm(PALM_KEY).text(text));
* const response = await data.json();

@@ -43,3 +43,3 @@ * ```

* .addStopSequence("==");
* const data = await fetch(palm(API_KEY).text(text));
* const data = await fetch(palm(PALM_KEY).text(text));
* const response = await data.json();

@@ -46,0 +46,0 @@ * ```

/**
* This file was generated by scripts/make-types.js on 2023-06-14T18:16:21.489Z
* Do not edit this file manually.
*/
* This file was generated by scripts/make-types.js on 2023-06-14T18:16:21.489Z
* Do not edit this file manually.
*/
/**

@@ -6,0 +6,0 @@ * A collection of source attributions for a piece of content. */

/**
* This file was generated by scripts/make-types.js on 2023-06-14T18:16:21.489Z
* Do not edit this file manually.
*/
* This file was generated by scripts/make-types.js on 2023-06-14T18:16:21.489Z
* Do not edit this file manually.
*/
export {};
//# sourceMappingURL=types.js.map
{
"name": "@google-labs/palm-lite",
"version": "0.0.2",
"version": "0.0.3",
"description": "A zero-dependency client for PaLM APIs",

@@ -10,8 +10,87 @@ "main": "./dist/src/index.js",

"scripts": {
"test": "FORCE_COLOR=1 ava",
"build": "FORCE_COLOR=1 tsc --b",
"make-types": "node ./scripts/make-types.js",
"make-models": "node ./scripts/make-models.js",
"watch": "FORCE_COLOR=1 tsc --b --watch"
"generate:docs": "wireit",
"test": "wireit",
"build": "wireit",
"build:tsc": "wireit",
"make-types": "wireit",
"make-models": "wireit",
"lint": "wireit"
},
"wireit": {
"build": {
"dependencies": [
"build:tsc"
]
},
"build:tsc": {
"command": "tsc -b",
"env": {
"FORCE_COLOR": "1"
},
"files": [
"src/**/*.ts",
"tests/**/*.ts",
"tsconfig.json",
"../../core/tsconfig/base.json"
],
"output": [
"dist/"
],
"clean": "if-file-deleted"
},
"test": {
"command": "ava",
"env": {
"FORCE_COLOR": "1"
},
"dependencies": [
"build:tsc"
],
"files": [],
"output": []
},
"lint": {
"command": "eslint . --ext .ts",
"env": {
"FORCE_COLOR": "1"
},
"files": [
"src/**/*.ts",
"tests/**/*.ts"
],
"output": []
},
"generate:docs": {
"command": "typedoc --plugin typedoc-plugin-markdown",
"files": [
"src/**/*.ts",
"tsconfig.json",
"../../core/tsconfig/base.json"
],
"output": [
"docs/api/"
]
},
"make-types": {
"command": "node ./scripts/make-types.js",
"dependencies": [
"../discovery-types:build"
],
"files": [
"scripts/make-types.js"
],
"output": [
"src/types.ts"
]
},
"make-models": {
"command": "node ./scripts/make-models.js",
"files": [
"scripts/make-models.js"
],
"output": [
"src/models.ts"
]
}
},
"repository": {

@@ -25,2 +104,3 @@ "type": "git",

"ava": {
"timeout": "30s",
"files": [

@@ -46,10 +126,11 @@ "tests/**/*.ts"

"@ava/typescript": "^4.0.0",
"@google-labs/discovery-types": "*",
"@google-labs/tsconfig": "*",
"@types/node": "^18.16.3",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"@types/node": "^18.16.3",
"ava": "^5.2.0",
"typescript": "^5.0.4",
"@google-labs/tsconfig": "*",
"@google-labs/discovery-types": "*"
"typedoc": "^0.25.1",
"typescript": "^5.0.4"
}
}

@@ -32,7 +32,7 @@ # palm-lite

// Grab the API_KEY somehow. In this example, we're using an environment variable.
const API_KEY = process.env.API_KEY;
// Grab the PALM_KEY somehow. In this example, we're using an environment variable.
const PALM_KEY = process.env.PALM_KEY;
// Create a `Request` object.
const request = palm(API_KEY).message({
const request = palm(PALM_KEY).message({
prompt: {

@@ -76,3 +76,3 @@ messages: [{ content: "Hello there!" }],

// Feed it to the `text` function
const request = palm(API_KEY).text(text);
const request = palm(PALM_KEY).text(text);

@@ -83,3 +83,3 @@ // ... Later in code

// Feed it to the `text` function again
const request2 = palm(API_KEY).text(text);
const request2 = palm(PALM_KEY).text(text);
```

@@ -99,3 +99,3 @@

const request = palm(process.env.API_KEY).text(text);
const request = palm(process.env.PALM_KEY).text(text);
const data = await fetch(request);

@@ -112,3 +112,3 @@ const response = await data.json();

const request = palm(process.env.API_KEY).message(chat);
const request = palm(process.env.PALM_KEY).message(chat);
const data = await fetch(request);

@@ -120,3 +120,3 @@ const response = await data.json();

{
const request = palm(process.env.API_KEY).embedding({
const request = palm(process.env.PALM_KEY).embedding({
text: "I love you",

@@ -123,0 +123,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet