Installation
First, install enochian.ProgramState using the OpenAIBackend.
Prompt Studio
You can optionally run it with Enochian Studio as well, a web view for the prompts being sent in. First, start the server.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Get started in a few commands
pnpm i enochian-js enochian-studio
npm i enochian-js enochian-studio
ProgramState using the OpenAIBackend.
import ProgramState from 'enochian-js';
const s = new ProgramState().fromOpenAI();
pip install "sglang[all]"
pip install flashinfer -i https://flashinfer.ai/whl/cu121/torch2.4/
python -m sglang.launch_server \
--model-path meta-llama/Meta-Llama-3-8B-Instruct \
--port 30000
import ProgramState from 'enochian-js';
async function multiTurnQuestion(
s: ProgramState,
question1: string,
question2: string,
): Promise<[string | undefined, string | undefined]> {
// If SGLang
await s.fromSGL('http://localhost:30000');
// If OpenAI
// s.fromOpenAI({ modelName: 'gpt-4o-mini' });
await s
.add(s.system`You are a helpful assistant.`)
.add(s.user`${question1}`)
.add(s.assistant`${s.gen('answer1')}`);
await s
.add(s.user`${question2}`)
.add(s.assistant`No problem! ${s.gen('answer2')}`);
console.log(s.get('answer1'), s.get('answer2'));
return [s.get('answer1'), s.get('answer2')];
}
const s = new ProgramState();
multiTurnQuestion(s, 'Tell me a joke', 'Tell me a better one');
pnpm exec enochian studio
npm enochian studio
import ProgramState from 'enochian-js';
async function multiTurnQuestion(
s: ProgramState,
question1: string,
question2: string,
): Promise<[string | undefined, string | undefined]> {
await s.fromSGL('http://localhost:30000');
// ADD THIS
s.beginDebugRegion({
debugName: 'multiTurnQuestion',
});
await s
.add(s.system`You are a helpful assistant.`)
.add(s.user`${question1}`)
.add(s.assistant`${s.gen('answer1')}`);
await s
.add(s.user`${question2}`)
.add(s.assistant`No problem! ${s.gen('answer2')}`);
console.log(s.get('answer1'), s.get('answer2'));
return [s.get('answer1'), s.get('answer2')];
}
const s = new ProgramState();
multiTurnQuestion(s, 'Tell me a joke', 'Tell me a better one');
