New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

polyfact

Package Overview
Dependencies
Maintainers
3
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

polyfact - npm Package Compare versions

Comparing version 0.1.9 to 0.1.10

dist/cmd/api.d.ts

3

examples/counter.ts

@@ -23,4 +23,7 @@ import { generateWithType, t } from "../lib/index";

}),
{
provider: "cohere",
},
),
);
})();

@@ -34,5 +34,15 @@ import fetch from "node-fetch";

export type GenerationOptions = {
provider?: "openai" | "cohere";
};
async function generateWithTokenUsage(
task: string,
options: GenerationOptions = {},
): Promise<{ result: string; tokenUsage: { input: number; output: number } }> {
if (!POLYFACT_TOKEN) {
throw new Error(
"Please put your polyfact token in the POLYFACT_TOKEN environment variable. You can get one at https://app.polyfact.com",
);
}
const res = await fetch(`${POLYFACT_ENDPOINT}/generate`, {

@@ -44,3 +54,3 @@ method: "POST",

},
body: JSON.stringify({ task }),
body: JSON.stringify({ task, provider: options.provider || "openai" }),
}).then((res) => res.json());

@@ -55,4 +65,4 @@

async function generate(task: string): Promise<string> {
const res = await generateWithTokenUsage(task);
async function generate(task: string, options: GenerationOptions = {}): Promise<string> {
const res = await generateWithTokenUsage(task, options);

@@ -59,0 +69,0 @@ return res.result;

5

lib/index.ts

@@ -1,2 +0,2 @@

import { generate, generateWithTokenUsage } from "./generate";
import { generate, generateWithTokenUsage, GenerationOptions } from "./generate";
import {

@@ -6,2 +6,3 @@ generateWithType,

} from "./probabilistic_helpers/generateWithType";
import { transcribe } from "./transcribe";
import { t } from "./probabilistic_helpers/types";

@@ -17,2 +18,4 @@ import { splitString } from "./split";

t,
GenerationOptions,
transcribe,
};
/* eslint-disable no-use-before-define */
import * as t from "io-ts";
import fetch from "node-fetch";
import { generate, generateWithTokenUsage } from "../index";
import { generate, generateWithTokenUsage, GenerationOptions } from "../index";

@@ -85,2 +85,3 @@ function typePartial2String(entries: [string, any][], indent: number, partial: boolean): string {

type: t.TypeC<T>,
options: GenerationOptions = {},
): Promise<{ result: t.TypeOf<t.TypeC<T>>; tokenUsage: { input: number; output: number } }> {

@@ -92,2 +93,3 @@ const typeFormat = tsio2String(type);

generateTypedPrompt(typeFormat, task),
options,
);

@@ -123,6 +125,7 @@

type: t.TypeC<T>,
options: GenerationOptions = {},
): Promise<t.TypeOf<t.TypeC<T>>> {
const res = await generateWithTypeWithTokenUsage(task, type);
const res = await generateWithTypeWithTokenUsage(task, type, options);
return res.result;
}
{
"name": "polyfact",
"version": "0.1.9",
"version": "0.1.10",
"main": "dist/index.js",

@@ -10,2 +10,3 @@ "types": "dist/index.d.ts",

"dependencies": {
"form-data": "^4.0.0",
"fp-ts": "^2.16.0",

@@ -43,4 +44,4 @@ "io-ts": "^2.2.20",

"cmd:build": "esbuild cmd/index.ts --bundle --outfile=build/polyfact.tmp --platform=node && echo -n '#!/usr/bin/env node\n' | cat - build/polyfact.tmp > build/polyfact && rm build/polyfact.tmp",
"build": "tsc lib/index.ts --declaration --outDir dist"
"build": "tsc -p tsconfig.json --declaration --outDir dist"
}
}

@@ -19,3 +19,3 @@ {

"outDir": "./dist",
"baseUrl": "src/",
"baseUrl": "lib/",
"paths": {

@@ -22,0 +22,0 @@ "@/*": ["*"]

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc