Skip to content

Commit

Permalink
Serialize and Deserialize chain state
Browse files Browse the repository at this point in the history
We want to allow to store prompt state half compiled. This is helpful
when using tool calls where user needs to receive a response from the AI that contains a tool call, do some work and respond back with the result of that work. In this scenario we need to serialize current compilation state to restart the compilation from that point.
  • Loading branch information
andresgutgon committed Jan 3, 2025
1 parent d242b71 commit c2cdd49
Show file tree
Hide file tree
Showing 29 changed files with 2,364 additions and 820 deletions.
10 changes: 0 additions & 10 deletions .eslintrc.json

This file was deleted.

56 changes: 56 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Linter & Types

on:
pull_request:
branches:
- main
jobs:
lint:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 9
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Node.js dependencies
run: pnpm install

- name: Prettier
run: pnpm prettier:check

- name: Node.js Lint
run: pnpm lint

- name: TypeScript
run: pnpm tc

50 changes: 50 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Tests

on:
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 9
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Node.js dependencies
run: pnpm install

- name: Node.js Test
env:
NODE_ENV: test
run: pnpm test
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.*
dist
build
**/tests/fixtures
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"semi": false,
"jsxSingleQuote": true,
"singleQuote": true,
"trailingComma": "all"
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ This is just a small example of what PromptL can do. It is a powerful tool that

## Links

[Website](https://promptl.ai/) | [Documentation](https://docs.latitude.so/promptl/getting-started/introduction)
[Website](https://promptl.ai/) | [Documentation](https://docs.latitude.so/promptl/getting-started/introduction)
63 changes: 63 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import typescriptEslintEslintPlugin from '@typescript-eslint/eslint-plugin'
import prettier from 'eslint-plugin-prettier'
import globals from 'globals'
import tsParser from '@typescript-eslint/parser'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import js from '@eslint/js'
import { FlatCompat } from '@eslint/eslintrc'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
})

export default [
{
ignores: ['**/.*.js', '**/node_modules/', '**/dist/'],
},
...compat.extends('eslint:recommended'),
{
plugins: {
'@typescript-eslint': typescriptEslintEslintPlugin,
'prettier': prettier,
},

languageOptions: {
globals: {
...globals.node,
...globals.browser,
},

parser: tsParser,
},

settings: {
'import/resolver': {
typescript: {
project: './tsconfig.json',
},
},
},

rules: {
'no-constant-condition': 'off',
'no-unused-vars': 'off',

'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
},
},
{
files: ['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'],
},
]
39 changes: 0 additions & 39 deletions eslint.js

This file was deleted.

8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"test": "vitest run",
"test:watch": "vitest",
"prettier": "prettier --write src/**/*.ts",
"prettier:check": "prettier --check src/**/*.ts --ignore-path .prettierrcignore",
"lint": "eslint src",
"tc": "tsc --noEmit"
},
Expand All @@ -39,10 +40,17 @@
"zod": "^3.23.8"
},
"devDependencies": {
"eslint": "^9.17.0",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.17.0",
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-typescript": "^11.1.6",
"@types/estree": "^1.0.1",
"@types/node": "^20.12.12",
"@typescript-eslint/eslint-plugin": "^8.19.0",
"eslint-plugin-prettier": "^5.2.1",
"globals": "^15.14.0",
"prettier": "^3.4.2",
"rollup": "^4.10.0",
"rollup-plugin-dts": "^6.1.1",
"tslib": "^2.8.1",
Expand Down
Loading

0 comments on commit c2cdd49

Please sign in to comment.