Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
name: Deploy Docusaurus
name: CI/CD Pipeline

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
test-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -22,17 +25,23 @@ jobs:
with:
node-version: 22
cache: 'pnpm'
cache-dependency-path: docs/pnpm-lock.yaml

- name: Install dependencies
- name: Install Root Dependencies
run: pnpm install --frozen-lockfile

- name: Run Eva-Judge Tests
run: pnpm run test:coverage

- name: Install Docs dependencies
run: pnpm install --frozen-lockfile
working-directory: docs

- name: Build
- name: Build Docs
run: pnpm run build
working-directory: docs

- name: Deploy
- name: Deploy to GH Pages
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ providers:
```yml
providers:
- id: openai:gpt-5.2
config:
config: # Any Vercel ai-sdk option: https://ai-sdk.dev/docs/reference/ai-sdk-core/generate-text#api-signature
temperature: 0
```

Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ providers:
```yml
providers:
- id: openai:gpt-5.2
config:
config: # Any Vercel ai-sdk option: https://ai-sdk.dev/docs/reference/ai-sdk-core/generate-text#api-signature
temperature: 0
```

Expand Down
17 changes: 17 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,21 @@ module.exports = {
transform: {
...tsJestTransformCfg,
},
coverageDirectory: "coverage",
coverageProvider: "v8",
collectCoverageFrom: [
"src/**/*.{ts,js}",
"!src/**/*.d.ts",
"!src/types/**",
"!**/node_modules/**"
],
coverageReporters: ["text", "lcov", "clover"],
coverageThreshold: {
global: {
branches: 90,
functions: 95,
lines: 95,
statements: 95,
},
},
};
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eva-llm/eva-parser",
"version": "1.0.2",
"version": "1.0.3",
"description": "A converter for Promptfoo test formats and into the EVA-LLM ecosystem",
"main": "dst/index.js",
"types": "dst/index.d.ts",
Expand All @@ -13,7 +13,8 @@
"scripts": {
"build": "tsc",
"prepare": "pnpm run build",
"test": "jest"
"test": "jest",
"test:coverage": "jest --coverage"
},
"repository": {
"type": "git",
Expand Down
21 changes: 10 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import { parse } from 'yaml';

import {
ASSERT_NAMES,
type AssertT,
type ProviderObjT,
type ModelOptionsT,
type TAssert,
type TProviderObj,
type TVercelOptions,
} from './types';


export * from './types';

const parseProvider = (providerObj: string | ProviderObjT) => {
const options: ModelOptionsT = {};
const parseProvider = (providerObj: string | TProviderObj) => {
let options: TVercelOptions = {};

if (typeof providerObj === 'string') {
const [ provider, model ] = providerObj.split(':');
Expand All @@ -21,10 +21,9 @@ const parseProvider = (providerObj: string | ProviderObjT) => {
}

const [ provider, model ] = providerObj.id.split(':');
const temperature = providerObj.config?.temperature;

if (temperature !== undefined) {
options.temperature = temperature;
if (providerObj.config !== undefined) {
options = providerObj.config;
}

return { provider, model, options };
Expand All @@ -37,8 +36,8 @@ const injectVars = (prompt: string, vars: undefined | Record<string, any>) => {
return Mustache.render(prompt, vars);
}

const parseAssert = (fooAssert: any): Omit<AssertT, 'criteria'> => {
let assert: Omit<AssertT, 'criteria'> = {
const parseAssert = (fooAssert: any): Omit<TAssert, 'criteria'> => {
let assert: Omit<TAssert, 'criteria'> = {
name: fooAssert.type,
};

Expand Down Expand Up @@ -98,7 +97,7 @@ export function parsePromptfoo(yamlContent: string) {

const evaTest = {
vars: fooTest.vars,
asserts: [] as AssertT[],
asserts: [] as TAssert[],
};

for (const fooAssert of fooTest.assert) {
Expand Down
12 changes: 5 additions & 7 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export const ASSERT_NAMES = {
REGEX: 'regex',
} as const;

export type AssertName = (typeof ASSERT_NAMES)[keyof typeof ASSERT_NAMES];
export type TAssertName = (typeof ASSERT_NAMES)[keyof typeof ASSERT_NAMES];

export type AssertT = {
name: AssertName;
export type TAssert = {
name: TAssertName;
criteria: string;
threshold?: number;
provider?: string;
Expand All @@ -23,11 +23,9 @@ export type AssertT = {
case_sensitive?: boolean;
}

export type ProviderObjT = {
export type TProviderObj = {
id: string;
config: Record<string, any>;
}

export type ModelOptionsT = {
temperature?: number;
}
export type TVercelOptions = Record<string, any>;
Loading