@prism-lang/core
Version:
A programming language for uncertainty
58 lines • 1.82 kB
TypeScript
import { Runtime } from './runtime';
import { LLMProvider } from './llm-types';
export interface RunPrismOptions {
/** LLM provider to use for llm() calls */
llmProvider?: LLMProvider;
/** Additional global variables/functions to inject */
globals?: Record<string, any>;
/** Default LLM provider name (defaults to 'default') */
defaultProviderName?: string;
}
/**
* Simple helper to run Prism code in one call
*
* @example
* ```javascript
* const { runPrism } = require('@prism-lang/core');
* const result = await runPrism('x = 5 ~> 0.9; x * 2');
* console.log(result); // 10 with 90% confidence
* ```
*
* @example With LLM provider
* ```javascript
* const { runPrism } = require('@prism-lang/core');
* const { createProvider } = require('@prism-lang/llm');
*
* const result = await runPrism(
* 'response = llm("Hello"); response',
* { llmProvider: createProvider() }
* );
* ```
*/
export declare function runPrism(code: string, options?: RunPrismOptions): Promise<any>;
/**
* Create a configured Prism runtime
* Useful when you want to reuse the same runtime for multiple executions
*
* Note: Since the runtime doesn't support direct global injection,
* you'll need to execute code that sets globals first.
*
* @example
* ```javascript
* const { createPrismRuntime, parse } = require('@prism-lang/core');
*
* const runtime = createPrismRuntime();
*
* // Set globals by executing assignment code
* const setupAst = parse('PI = 3.14159');
* await runtime.execute(setupAst);
*
* const ast1 = parse('x = PI * 2');
* await runtime.execute(ast1);
*
* const ast2 = parse('x + 1');
* const result = await runtime.execute(ast2);
* ```
*/
export declare function createPrismRuntime(options?: RunPrismOptions): Runtime;
//# sourceMappingURL=helpers.d.ts.map