feat(gpt-runner-cli): complete cli
This commit is contained in:
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -16,6 +16,8 @@
|
||||
"Chatgpt",
|
||||
"clsx",
|
||||
"codicon",
|
||||
"colorette",
|
||||
"consola",
|
||||
"esno",
|
||||
"execa",
|
||||
"gptr",
|
||||
|
||||
@@ -2,11 +2,6 @@ import { defineBuildConfig } from 'unbuild'
|
||||
|
||||
export default defineBuildConfig({
|
||||
entries: [
|
||||
{
|
||||
builder: 'rollup',
|
||||
input: 'src/index',
|
||||
name: 'index',
|
||||
},
|
||||
{
|
||||
builder: 'rollup',
|
||||
input: 'src/cli',
|
||||
|
||||
@@ -13,21 +13,18 @@
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nicepkg/gpt-runner",
|
||||
"directory": "packages/cli"
|
||||
"directory": "packages/gpt-runner-cli"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/nicepkg/gpt-runner/issues"
|
||||
},
|
||||
"keywords": [],
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.mjs"
|
||||
}
|
||||
},
|
||||
"main": "./dist/index.mjs",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"keywords": [
|
||||
"gpt-runner",
|
||||
"chatgpt",
|
||||
"prompt",
|
||||
"langchain",
|
||||
"ai"
|
||||
],
|
||||
"bin": {
|
||||
"gptr": "./bin/gpt-runner.mjs"
|
||||
},
|
||||
@@ -43,18 +40,14 @@
|
||||
"stub": "unbuild --stub"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ampproject/remapping": "^2.2.1",
|
||||
"@rollup/pluginutils": "^5.0.2",
|
||||
"@nicepkg/gpt-runner-config": "workspace:*",
|
||||
"@nicepkg/gpt-runner-core": "workspace:*",
|
||||
"@nicepkg/gpt-runner-shared": "workspace:*",
|
||||
"@nicepkg/gpt-runner-web": "workspace:*",
|
||||
"cac": "^6.7.14",
|
||||
"chokidar": "^3.5.3",
|
||||
"colorette": "^2.0.20",
|
||||
"consola": "^3.1.0",
|
||||
"fast-glob": "^3.2.12",
|
||||
"magic-string": "^0.30.0",
|
||||
"pathe": "^1.1.0",
|
||||
"perfect-debounce": "^1.0.0"
|
||||
"execa": "^7.1.1",
|
||||
"wait-port": "^1.0.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,41 +1,87 @@
|
||||
import { cac } from 'cac'
|
||||
import { loadConfig } from '@nicepkg/gpt-runner-config'
|
||||
import { toArray } from '@nicepkg/gpt-runner-core'
|
||||
import { loadUserConfig } from '@nicepkg/gpt-runner-core'
|
||||
import { PathUtils, getLocalHostname, getPort, openInBrowser } from '@nicepkg/gpt-runner-shared/node'
|
||||
import { consola } from 'consola'
|
||||
import { cyan, green } from 'colorette'
|
||||
import { execa } from 'execa'
|
||||
import waitPort from 'wait-port'
|
||||
import { Debug } from '@nicepkg/gpt-runner-shared/common'
|
||||
import { version } from '../package.json'
|
||||
import type { CliOptions } from './types'
|
||||
import { build } from './index'
|
||||
|
||||
const __dirname = PathUtils.getCurrentDirName(import.meta.url)
|
||||
const startServerJsPath = PathUtils.resolve(__dirname, '../node_modules/@nicepkg/gpt-runner-web/dist/start-server.mjs')
|
||||
|
||||
export async function startCli(cwd = process.cwd(), argv = process.argv, options: CliOptions = {}) {
|
||||
const cli = cac('gptr')
|
||||
|
||||
cli
|
||||
.command('[...patterns]', 'Glob patterns', {
|
||||
.command('[...rootPaths]', 'root path', {
|
||||
ignoreOptionDefaultValue: true,
|
||||
})
|
||||
.option('-o, --out-file <file>', 'Output file', {
|
||||
default: cwd,
|
||||
.option('-p, --port [port number]', 'Server port', {
|
||||
default: 3003,
|
||||
})
|
||||
.option('-c, --config [file]', 'Config file')
|
||||
.option('--no-open', 'Open in browser')
|
||||
.option('-c, --config [file]', 'Config file path')
|
||||
.option('-w, --watch', 'Watch for file changes')
|
||||
.option('--preflights', 'Enable preflights', { default: true })
|
||||
.option('-m, --minify', 'Minify generated CSS', { default: false })
|
||||
.action(async (patterns: Array<string>, flags) => {
|
||||
.option('--debug', 'Debug mode')
|
||||
.action(async (rootPaths: Array<string>, flags) => {
|
||||
Object.assign(options, {
|
||||
cwd,
|
||||
...flags,
|
||||
rootPath: rootPaths?.[0] || options.rootPath,
|
||||
})
|
||||
|
||||
if (patterns)
|
||||
options.patterns = patterns
|
||||
const { config } = await loadConfig(cwd, options.config)
|
||||
if (options.debug)
|
||||
process.env.DEBUG = 'enabled'
|
||||
|
||||
const entries = toArray(config.cli?.entry || options)
|
||||
await Promise.all(entries.map(entry =>
|
||||
build({
|
||||
...options,
|
||||
...entry,
|
||||
}),
|
||||
))
|
||||
const debug = new Debug('gpt-runner-cli')
|
||||
debug.log('parse cli options', options)
|
||||
|
||||
const { config } = await loadUserConfig(options.rootPath || options.cwd, options.config)
|
||||
|
||||
// TODO: add support for config file and watching
|
||||
debug.log('parse user config', config)
|
||||
|
||||
const finalPort = await getPort({
|
||||
defaultPort: options.port ?? 3003,
|
||||
autoFreePort: true,
|
||||
})
|
||||
|
||||
const startServerProcessPromise = execa('node', [startServerJsPath, '--port', String(finalPort)], {
|
||||
env: {
|
||||
...process.env,
|
||||
NODE_OPTIONS: '--experimental-fetch',
|
||||
NODE_NO_WARNINGS: '1',
|
||||
},
|
||||
})
|
||||
|
||||
startServerProcessPromise.on('error', (error) => {
|
||||
consola.error(error)
|
||||
})
|
||||
|
||||
const afterServerStartSuccess = () => {
|
||||
const getUrl = (isLocalIp = false) => {
|
||||
const localIp = getLocalHostname()
|
||||
return `http://${isLocalIp ? localIp : 'localhost'}:${finalPort}/#/chat?rootPath=${config.rootPath}`
|
||||
}
|
||||
|
||||
consola.success(`\n\n${green(`GPT-Runner web is at:\n\n${cyan(getUrl())}\n\n${cyan(getUrl(true))}\n`)}`)
|
||||
|
||||
if (options.open ?? true) {
|
||||
openInBrowser({
|
||||
url: getUrl(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
waitPort({
|
||||
port: finalPort,
|
||||
output: 'silent',
|
||||
}).then(afterServerStartSuccess).catch(consola.error)
|
||||
|
||||
await startServerProcessPromise
|
||||
})
|
||||
|
||||
cli.help()
|
||||
|
||||
@@ -1,150 +0,0 @@
|
||||
import { existsSync, promises as fs } from 'node:fs'
|
||||
import { basename, dirname, normalize, relative, resolve } from 'pathe'
|
||||
import fg from 'fast-glob'
|
||||
import { consola } from 'consola'
|
||||
import { cyan, dim, green } from 'colorette'
|
||||
import { debounce } from 'perfect-debounce'
|
||||
import { toArray } from '@nicepkg/gpt-runner-core'
|
||||
import type { SourceCodeTransformerEnforce, UserConfig } from '@nicepkg/gpt-runner-core'
|
||||
import { createContext } from '../../shared-integration/src/context'
|
||||
import { applyTransformers } from '../../shared-integration/src/transformers'
|
||||
import { version } from '../package.json'
|
||||
import { defaultConfig } from './config'
|
||||
import { PrettyError, handleError } from './errors'
|
||||
import { getWatcher } from './watcher'
|
||||
import type { CliOptions, ResolvedCliOptions } from './types'
|
||||
|
||||
const name = 'gptr'
|
||||
|
||||
export async function resolveOptions(options: CliOptions) {
|
||||
if (!options.patterns?.length) {
|
||||
throw new PrettyError(
|
||||
`No glob patterns, try ${cyan(`${name} <path/to/**/*>`)}`,
|
||||
)
|
||||
}
|
||||
|
||||
return options as ResolvedCliOptions
|
||||
}
|
||||
|
||||
export async function build(_options: CliOptions) {
|
||||
const fileCache = new Map<string, string>()
|
||||
|
||||
const cwd = _options.cwd || process.cwd()
|
||||
const options = await resolveOptions(_options)
|
||||
|
||||
async function loadConfig() {
|
||||
const ctx = createContext<UserConfig>(options.config, defaultConfig)
|
||||
const configSources = (await ctx.updateRoot(cwd)).sources.map(i => normalize(i))
|
||||
return { ctx, configSources }
|
||||
}
|
||||
|
||||
const { ctx, configSources } = await loadConfig()
|
||||
const files = await fg(options.patterns, { cwd, absolute: true })
|
||||
await Promise.all(
|
||||
files.map(async (file) => {
|
||||
fileCache.set(file, await fs.readFile(file, 'utf8'))
|
||||
}),
|
||||
)
|
||||
|
||||
consola.log(green(`${name} v${version}`))
|
||||
consola.start(`GPT Runner ${options.watch ? 'in watch mode...' : 'for production...'}`)
|
||||
|
||||
const debouncedBuild = debounce(
|
||||
async () => {
|
||||
generate(options).catch(handleError)
|
||||
},
|
||||
100,
|
||||
)
|
||||
|
||||
const startWatcher = async () => {
|
||||
if (!options.watch)
|
||||
return
|
||||
const { patterns } = options
|
||||
|
||||
const watcher = await getWatcher(options)
|
||||
|
||||
if (configSources.length)
|
||||
watcher.add(configSources)
|
||||
|
||||
watcher.on('all', async (type, file) => {
|
||||
const absolutePath = resolve(cwd, file)
|
||||
|
||||
if (configSources.includes(absolutePath)) {
|
||||
await ctx.reloadConfig()
|
||||
consola.info(`${cyan(basename(file))} changed, setting new config`)
|
||||
}
|
||||
else {
|
||||
consola.log(`${green(type)} ${dim(file)}`)
|
||||
|
||||
if (type.startsWith('unlink'))
|
||||
fileCache.delete(absolutePath)
|
||||
else
|
||||
fileCache.set(absolutePath, await fs.readFile(absolutePath, 'utf8'))
|
||||
}
|
||||
|
||||
debouncedBuild()
|
||||
})
|
||||
|
||||
consola.info(
|
||||
`Watching for changes in ${
|
||||
toArray(patterns)
|
||||
.map(i => cyan(i))
|
||||
.join(', ')}`,
|
||||
)
|
||||
}
|
||||
|
||||
await generate(options)
|
||||
|
||||
await startWatcher().catch(handleError)
|
||||
|
||||
function transformFiles(sources: { id: string; code: string; transformedCode?: string | undefined }[], enforce: SourceCodeTransformerEnforce = 'default') {
|
||||
return Promise.all(
|
||||
sources.map(({ id, code, transformedCode }) => new Promise<{ id: string; code: string; transformedCode: string | undefined }>((resolve) => {
|
||||
applyTransformers(ctx, code, id, enforce)
|
||||
.then((transformsRes) => {
|
||||
resolve({ id, code, transformedCode: transformsRes?.code || transformedCode })
|
||||
})
|
||||
})))
|
||||
}
|
||||
|
||||
async function generate(options: ResolvedCliOptions) {
|
||||
const sourceCache = Array.from(fileCache).map(([id, code]) => ({ id, code }))
|
||||
|
||||
const outFile = resolve(options.cwd || process.cwd(), options.outFile ?? 'uno.css')
|
||||
|
||||
const preTransform = await transformFiles(sourceCache, 'pre')
|
||||
const defaultTransform = await transformFiles(preTransform)
|
||||
const postTransform = await transformFiles(defaultTransform, 'post')
|
||||
|
||||
// update source file
|
||||
await Promise.all(
|
||||
postTransform
|
||||
.filter(({ transformedCode }) => !!transformedCode)
|
||||
.map(({ transformedCode, id }) => new Promise<void>((resolve) => {
|
||||
if (existsSync(id))
|
||||
fs.writeFile(id, transformedCode as string, 'utf-8').then(resolve)
|
||||
})),
|
||||
)
|
||||
|
||||
const { css, matched } = await ctx.uno.generate(
|
||||
[...postTransform.map(({ code, transformedCode }) => transformedCode ?? code)].join('\n'),
|
||||
{
|
||||
preflights: options.preflights,
|
||||
minify: options.minify,
|
||||
},
|
||||
)
|
||||
|
||||
const dir = dirname(outFile)
|
||||
if (!existsSync(dir))
|
||||
await fs.mkdir(dir, { recursive: true })
|
||||
await fs.writeFile(outFile, css, 'utf-8')
|
||||
|
||||
if (!options.watch) {
|
||||
consola.success(
|
||||
`${[...matched].length} utilities generated to ${cyan(
|
||||
relative(process.cwd(), outFile),
|
||||
)}\n`,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,9 @@
|
||||
/** Mark some properties as required, leaving others unchanged */
|
||||
declare type MarkRequired<T, RK extends keyof T> = Exclude<T, RK> & Required<Pick<T, RK>>
|
||||
|
||||
export interface CliOptions {
|
||||
cwd?: string
|
||||
patterns?: Array<string>
|
||||
outFile?: string
|
||||
watch?: boolean
|
||||
port?: number
|
||||
rootPath?: string
|
||||
open?: boolean
|
||||
config?: string
|
||||
|
||||
// generate options
|
||||
preflights?: boolean
|
||||
minify?: boolean
|
||||
watch?: boolean
|
||||
debug?: boolean
|
||||
}
|
||||
|
||||
export type ResolvedCliOptions = MarkRequired<CliOptions, 'patterns'>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { FSWatcher } from 'chokidar'
|
||||
import type { CliOptions } from './types'
|
||||
|
||||
// TODO: move into core
|
||||
let watcher: FSWatcher
|
||||
|
||||
export async function getWatcher(options?: CliOptions) {
|
||||
@@ -11,7 +12,7 @@ export async function getWatcher(options?: CliOptions) {
|
||||
const { watch } = await import('chokidar')
|
||||
const ignored = ['**/{.git,node_modules}/**']
|
||||
// cli may create multiple watchers
|
||||
const newWatcher = watch(options?.patterns as string[], {
|
||||
const newWatcher = watch([] as string[], {
|
||||
ignoreInitial: true,
|
||||
ignorePermissionErrors: true,
|
||||
ignored,
|
||||
|
||||
@@ -14,7 +14,12 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/nicepkg/gpt-runner/issues"
|
||||
},
|
||||
"keywords": [],
|
||||
"keywords": [
|
||||
"gpt-runner",
|
||||
"chatgpt",
|
||||
"prompt",
|
||||
"ai"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
@@ -41,4 +46,4 @@
|
||||
"@nicepkg/gpt-runner-shared": "workspace:*",
|
||||
"unconfig": "^0.3.9"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ export async function loadUserConfig<U extends IUserConfig = IUserConfig>(
|
||||
}
|
||||
}
|
||||
else {
|
||||
configOrPath = inlineConfig.configFile || process.cwd()
|
||||
configOrPath = inlineConfig.configFile || cwd
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,14 +30,5 @@ export default defineBuildConfig({
|
||||
rollup: {
|
||||
emitCJS: true,
|
||||
inlineDependencies: true,
|
||||
dts: {
|
||||
compilerOptions: {
|
||||
baseUrl: '.',
|
||||
paths: {
|
||||
// fix types error
|
||||
'@kvs/storage': ['./node_modules/@kvs/storage/'],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
1
packages/gpt-runner-shared/index.cjs
Normal file
1
packages/gpt-runner-shared/index.cjs
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./dist/common.cjs')
|
||||
1
packages/gpt-runner-shared/index.d.ts
vendored
Normal file
1
packages/gpt-runner-shared/index.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/common'
|
||||
1
packages/gpt-runner-shared/index.mjs
Normal file
1
packages/gpt-runner-shared/index.mjs
Normal file
@@ -0,0 +1 @@
|
||||
export * from './dist/common'
|
||||
@@ -9,4 +9,5 @@ export interface SingleChat {
|
||||
messages: SingleChatMessage[]
|
||||
singleFileConfig: SingleFileConfig
|
||||
status: ChatMessageStatus
|
||||
createAt: number
|
||||
}
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
export class PathUtils {
|
||||
static getCurrentDirName(importMetaUrl: string) {
|
||||
const __filename = fileURLToPath(importMetaUrl)
|
||||
const __dirname = path.dirname(__filename)
|
||||
return __dirname
|
||||
}
|
||||
|
||||
static join(...paths: string[]) {
|
||||
return path.join(...paths)
|
||||
}
|
||||
|
||||
@@ -1,17 +1,8 @@
|
||||
import type { Response } from 'express'
|
||||
import type { z } from 'zod'
|
||||
import type { FailResponse, SuccessResponse } from '../../common'
|
||||
import { verifyZod } from '../../common'
|
||||
|
||||
interface CustomResponse<T = any> {
|
||||
type: 'Success' | 'Fail'
|
||||
status?: number
|
||||
message?: string
|
||||
data?: T
|
||||
}
|
||||
|
||||
export type SuccessResponse<T = any> = Omit<CustomResponse<T>, 'type'> & { type: 'Success' }
|
||||
export type FailResponse<T = any> = Omit<CustomResponse<T>, 'type'> & { type: 'Fail' }
|
||||
|
||||
export function buildSuccessResponse<T>(options: Omit<SuccessResponse<T>, 'type'>): SuccessResponse<T> {
|
||||
return {
|
||||
type: 'Success',
|
||||
|
||||
@@ -80,6 +80,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/vscode": "^1.71.0",
|
||||
"esno": "^0.16.3"
|
||||
"esno": "^0.16.3",
|
||||
"execa": "^7.1.1",
|
||||
"fs-extra": "^11.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { dirname, join } from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
import fs from 'fs-extra'
|
||||
import { execa } from 'execa'
|
||||
import { PathUtils } from '@nicepkg/gpt-runner-shared/node'
|
||||
|
||||
const dir = typeof __dirname === 'string' ? __dirname : dirname(fileURLToPath(import.meta.url))
|
||||
const dir = PathUtils.getCurrentDirName(import.meta.url)
|
||||
const root = dirname(dir)
|
||||
|
||||
async function publish() {
|
||||
|
||||
@@ -36,6 +36,7 @@ export default defineBuildConfig({
|
||||
],
|
||||
rollup: {
|
||||
emitCJS: true,
|
||||
resolve: {},
|
||||
},
|
||||
hooks: {
|
||||
'rollup:options': function (ctx, rollupOptions) {
|
||||
|
||||
@@ -54,7 +54,7 @@ export const createSidebarTreeSlice: StateCreator<
|
||||
parentId: null,
|
||||
path: '',
|
||||
name: chatInstance?.name || DEFAULT_CHAT_NAME,
|
||||
createAt: Date.now(),
|
||||
createAt: chatInstance?.createAt || Date.now(),
|
||||
}
|
||||
|
||||
return chatInfo
|
||||
@@ -175,6 +175,7 @@ export const createSidebarTreeSlice: StateCreator<
|
||||
messages: [],
|
||||
singleFileConfig: gptFileTreeItem?.otherInfo?.singleFileConfig || {},
|
||||
status: ChatMessageStatus.Success,
|
||||
createAt: Date.now(),
|
||||
})
|
||||
|
||||
state.updateActiveChatId(chatInstance.id)
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import path from 'node:path'
|
||||
import { defineConfig } from 'vite'
|
||||
import React from '@vitejs/plugin-react'
|
||||
import { EnvConfig } from '@nicepkg/gpt-runner-shared'
|
||||
import { EnvConfig } from '@nicepkg/gpt-runner-shared/common'
|
||||
import { PathUtils } from '@nicepkg/gpt-runner-shared/node'
|
||||
|
||||
const __dirname = PathUtils.getCurrentDirName(import.meta.url)
|
||||
|
||||
const resolvePath = (...paths: string[]) => path.resolve(__dirname, ...paths)
|
||||
|
||||
|
||||
@@ -4,10 +4,12 @@ import type { Express } from 'express'
|
||||
import express from 'express'
|
||||
import cors from 'cors'
|
||||
import history from 'connect-history-api-fallback'
|
||||
import { getPort } from '@nicepkg/gpt-runner-shared/node'
|
||||
import { PathUtils, getPort } from '@nicepkg/gpt-runner-shared/node'
|
||||
import { processControllers } from './src/controllers'
|
||||
import { errorHandlerMiddleware } from './src/middleware'
|
||||
|
||||
const __dirname = PathUtils.getCurrentDirName(import.meta.url)
|
||||
|
||||
const resolvePath = (...paths: string[]) => path.resolve(__dirname, ...paths)
|
||||
|
||||
export const clientDistPath = resolvePath('../dist/browser')
|
||||
@@ -15,7 +17,6 @@ export const clientDistPath = resolvePath('../dist/browser')
|
||||
export interface StartServerProps {
|
||||
port?: number
|
||||
autoFreePort?: boolean
|
||||
autoOpen?: boolean
|
||||
}
|
||||
|
||||
export async function startServer(props: StartServerProps): Promise<Express> {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { Request, Response } from 'express'
|
||||
import type { ChatStreamReqParams } from '@nicepkg/gpt-runner-shared/common'
|
||||
import type { ChatStreamReqParams, FailResponse, SuccessResponse } from '@nicepkg/gpt-runner-shared/common'
|
||||
import { ChatStreamReqParamsSchema, EnvConfig } from '@nicepkg/gpt-runner-shared/common'
|
||||
import type { FailResponse, SuccessResponse } from '@nicepkg/gpt-runner-shared/node'
|
||||
import { PathUtils, buildFailResponse, buildSuccessResponse, sendFailResponse, sendSuccessResponse, verifyParamsByZod } from '@nicepkg/gpt-runner-shared/node'
|
||||
import { loadUserConfig } from '@nicepkg/gpt-runner-core'
|
||||
import { chatgptChain } from '../services'
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
"stub": "unbuild --stub"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nicepkg/gpt-runner-core": "workspace:*",
|
||||
"@nicepkg/gpt-runner-shared": "workspace:*"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import type { UserConfig } from '@nicepkg/gpt-runner-core'
|
||||
import type { UserConfig as IUserConfig } from '@nicepkg/gpt-runner-shared/common'
|
||||
|
||||
export * from '@nicepkg/gpt-runner-core'
|
||||
export * from '@nicepkg/gpt-runner-shared/common'
|
||||
export * from '@nicepkg/gpt-runner-shared/node'
|
||||
|
||||
export type UserConfig = Omit<IUserConfig, 'rootPath'>
|
||||
|
||||
export function defineConfig(config: UserConfig) {
|
||||
return config
|
||||
}
|
||||
|
||||
export interface UserConfigDefaults {}
|
||||
|
||||
9
playground/gptr.config.ts
Normal file
9
playground/gptr.config.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { defineConfig } from '@nicepkg/gpt-runner'
|
||||
|
||||
export default defineConfig({
|
||||
model: {
|
||||
type: 'openai',
|
||||
modelName: 'gpt-3.5.turbo2',
|
||||
openaiKey: process.env.OPENAI_KEY!,
|
||||
},
|
||||
})
|
||||
@@ -7,5 +7,8 @@
|
||||
"build": "vite build",
|
||||
"update-post": "vite build",
|
||||
"serve": "vite preview"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nicepkg/gpt-runner": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
||||
88
pnpm-lock.yaml
generated
88
pnpm-lock.yaml
generated
@@ -121,30 +121,21 @@ importers:
|
||||
|
||||
packages/gpt-runner:
|
||||
dependencies:
|
||||
'@nicepkg/gpt-runner-core':
|
||||
specifier: workspace:*
|
||||
version: link:../gpt-runner-core
|
||||
'@nicepkg/gpt-runner-shared':
|
||||
specifier: workspace:*
|
||||
version: link:../gpt-runner-shared
|
||||
|
||||
packages/gpt-runner-cli:
|
||||
dependencies:
|
||||
'@ampproject/remapping':
|
||||
specifier: ^2.2.1
|
||||
version: 2.2.1
|
||||
'@nicepkg/gpt-runner-config':
|
||||
specifier: workspace:*
|
||||
version: link:../gpt-runner-config
|
||||
'@nicepkg/gpt-runner-core':
|
||||
specifier: workspace:*
|
||||
version: link:../gpt-runner-core
|
||||
'@nicepkg/gpt-runner-shared':
|
||||
specifier: workspace:*
|
||||
version: link:../gpt-runner-shared
|
||||
'@rollup/pluginutils':
|
||||
specifier: ^5.0.2
|
||||
version: 5.0.2(rollup@3.21.7)
|
||||
'@nicepkg/gpt-runner-web':
|
||||
specifier: workspace:*
|
||||
version: link:../gpt-runner-web
|
||||
cac:
|
||||
specifier: ^6.7.14
|
||||
version: 6.7.14
|
||||
@@ -157,18 +148,12 @@ importers:
|
||||
consola:
|
||||
specifier: ^3.1.0
|
||||
version: 3.1.0
|
||||
fast-glob:
|
||||
specifier: ^3.2.12
|
||||
version: 3.2.12
|
||||
magic-string:
|
||||
specifier: ^0.30.0
|
||||
version: 0.30.0
|
||||
pathe:
|
||||
specifier: ^1.1.0
|
||||
version: 1.1.0
|
||||
perfect-debounce:
|
||||
specifier: ^1.0.0
|
||||
version: 1.0.0
|
||||
execa:
|
||||
specifier: ^7.1.1
|
||||
version: 7.1.1
|
||||
wait-port:
|
||||
specifier: ^1.0.4
|
||||
version: 1.0.4
|
||||
|
||||
packages/gpt-runner-config:
|
||||
dependencies:
|
||||
@@ -258,6 +243,12 @@ importers:
|
||||
esno:
|
||||
specifier: ^0.16.3
|
||||
version: 0.16.3
|
||||
execa:
|
||||
specifier: ^7.1.1
|
||||
version: 7.1.1
|
||||
fs-extra:
|
||||
specifier: ^11.1.1
|
||||
version: 11.1.1
|
||||
|
||||
packages/gpt-runner-web:
|
||||
dependencies:
|
||||
@@ -380,7 +371,11 @@ importers:
|
||||
specifier: ^4.3.9
|
||||
version: 4.3.9(@types/node@18.16.9)(terser@5.17.3)
|
||||
|
||||
playground: {}
|
||||
playground:
|
||||
devDependencies:
|
||||
'@nicepkg/gpt-runner':
|
||||
specifier: workspace:*
|
||||
version: link:../packages/gpt-runner
|
||||
|
||||
packages:
|
||||
|
||||
@@ -2192,10 +2187,12 @@ packages:
|
||||
dependencies:
|
||||
'@nodelib/fs.stat': 2.0.5
|
||||
run-parallel: 1.2.0
|
||||
dev: true
|
||||
|
||||
/@nodelib/fs.stat@2.0.5:
|
||||
resolution: {integrity: sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==}
|
||||
engines: {node: '>= 8'}
|
||||
dev: true
|
||||
|
||||
/@nodelib/fs.walk@1.2.8:
|
||||
resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==}
|
||||
@@ -2203,6 +2200,7 @@ packages:
|
||||
dependencies:
|
||||
'@nodelib/fs.scandir': 2.1.5
|
||||
fastq: 1.15.0
|
||||
dev: true
|
||||
|
||||
/@npmcli/config@6.1.6:
|
||||
resolution: {integrity: sha512-TM5dwgaz3Un2T5rdHQ6lX+Jj3TQxK6aV1U5OLByZiUS5qnA0NgC6U0aSESQVy80emToz8dtX3aniXD24wRnBaw==}
|
||||
@@ -2420,6 +2418,7 @@ packages:
|
||||
estree-walker: 2.0.2
|
||||
picomatch: 2.3.1
|
||||
rollup: 3.21.7
|
||||
dev: true
|
||||
|
||||
/@sigstore/protobuf-specs@0.1.0:
|
||||
resolution: {integrity: sha512-a31EnjuIDSX8IXBUib3cYLDRlPMU36AWX4xS8ysLaNu4ZzUesDiPt83pgrW2X1YLMe5L2HbDyaKK5BrL4cNKaQ==}
|
||||
@@ -2517,6 +2516,7 @@ packages:
|
||||
|
||||
/@types/estree@1.0.1:
|
||||
resolution: {integrity: sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==}
|
||||
dev: true
|
||||
|
||||
/@types/express-serve-static-core@4.17.35:
|
||||
resolution: {integrity: sha512-wALWQwrgiB2AWTT91CB62b6Yt0sNHpznUXeZEcnPU3DRdlDIz74x8Qg1UUYKSVFi+va5vKOLYRBI1bRKiLLKIg==}
|
||||
@@ -3054,7 +3054,6 @@ packages:
|
||||
engines: {node: '>=8'}
|
||||
dependencies:
|
||||
color-convert: 2.0.1
|
||||
dev: true
|
||||
|
||||
/ansi-styles@5.2.0:
|
||||
resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==}
|
||||
@@ -3494,7 +3493,6 @@ packages:
|
||||
dependencies:
|
||||
ansi-styles: 4.3.0
|
||||
supports-color: 7.2.0
|
||||
dev: true
|
||||
|
||||
/chalk@5.2.0:
|
||||
resolution: {integrity: sha512-ree3Gqw/nazQAPuJJEy+avdl7QfZMcUvmHIKgEZkGL+xOBzRvup5Hxo6LHuMceSxOabuJLJm5Yp/92R9eMmMvA==}
|
||||
@@ -3620,14 +3618,12 @@ packages:
|
||||
engines: {node: '>=7.0.0'}
|
||||
dependencies:
|
||||
color-name: 1.1.4
|
||||
dev: true
|
||||
|
||||
/color-name@1.1.3:
|
||||
resolution: {integrity: sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==}
|
||||
|
||||
/color-name@1.1.4:
|
||||
resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
|
||||
dev: true
|
||||
|
||||
/color-support@1.1.3:
|
||||
resolution: {integrity: sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==}
|
||||
@@ -3663,6 +3659,11 @@ packages:
|
||||
resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==}
|
||||
engines: {node: '>= 6'}
|
||||
|
||||
/commander@9.5.0:
|
||||
resolution: {integrity: sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==}
|
||||
engines: {node: ^12.20.0 || >=14}
|
||||
dev: false
|
||||
|
||||
/commondir@1.0.1:
|
||||
resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==}
|
||||
dev: true
|
||||
@@ -5082,6 +5083,7 @@ packages:
|
||||
|
||||
/estree-walker@2.0.2:
|
||||
resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==}
|
||||
dev: true
|
||||
|
||||
/esutils@2.0.3:
|
||||
resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==}
|
||||
@@ -5219,6 +5221,7 @@ packages:
|
||||
glob-parent: 5.1.2
|
||||
merge2: 1.4.1
|
||||
micromatch: 4.0.5
|
||||
dev: true
|
||||
|
||||
/fast-json-stable-stringify@2.1.0:
|
||||
resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==}
|
||||
@@ -5244,6 +5247,7 @@ packages:
|
||||
resolution: {integrity: sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==}
|
||||
dependencies:
|
||||
reusify: 1.0.4
|
||||
dev: true
|
||||
|
||||
/fault@1.0.4:
|
||||
resolution: {integrity: sha512-CJ0HCB5tL5fYTEA7ToAq5+kTwd++Borf1/bifxd9iT70QcXr4MRrO3Llf8Ifs70q+SJcGHFtnIE/Nw6giCtECA==}
|
||||
@@ -5655,7 +5659,6 @@ packages:
|
||||
/has-flag@4.0.0:
|
||||
resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==}
|
||||
engines: {node: '>=8'}
|
||||
dev: true
|
||||
|
||||
/has-property-descriptors@1.0.0:
|
||||
resolution: {integrity: sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==}
|
||||
@@ -6692,6 +6695,7 @@ packages:
|
||||
engines: {node: '>=12'}
|
||||
dependencies:
|
||||
'@jridgewell/sourcemap-codec': 1.4.15
|
||||
dev: true
|
||||
|
||||
/make-dir@2.1.0:
|
||||
resolution: {integrity: sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==}
|
||||
@@ -6931,6 +6935,7 @@ packages:
|
||||
/merge2@1.4.1:
|
||||
resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==}
|
||||
engines: {node: '>= 8'}
|
||||
dev: true
|
||||
|
||||
/methods@1.1.2:
|
||||
resolution: {integrity: sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==}
|
||||
@@ -7199,6 +7204,7 @@ packages:
|
||||
dependencies:
|
||||
braces: 3.0.2
|
||||
picomatch: 2.3.1
|
||||
dev: true
|
||||
|
||||
/mime-db@1.52.0:
|
||||
resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==}
|
||||
@@ -8016,6 +8022,7 @@ packages:
|
||||
|
||||
/pathe@1.1.0:
|
||||
resolution: {integrity: sha512-ODbEPR0KKHqECXW1GoxdDb+AZvULmXjVPy4rt+pGo2+TnjJTIPJQSVS6N63n8T2Ip+syHhbn52OewKicV0373w==}
|
||||
dev: true
|
||||
|
||||
/pathval@1.1.1:
|
||||
resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==}
|
||||
@@ -8025,10 +8032,6 @@ packages:
|
||||
resolution: {integrity: sha512-NOT9AcKiDGpnV/HBhI22Str++XWcErO/bALvHCuhv33owZW/CjH8KAFLZDCmu3727sihe0wTxpDhyGc6M8qacQ==}
|
||||
dev: true
|
||||
|
||||
/perfect-debounce@1.0.0:
|
||||
resolution: {integrity: sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA==}
|
||||
dev: false
|
||||
|
||||
/picocolors@1.0.0:
|
||||
resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==}
|
||||
|
||||
@@ -8226,6 +8229,7 @@ packages:
|
||||
|
||||
/queue-microtask@1.2.3:
|
||||
resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
|
||||
dev: true
|
||||
|
||||
/range-parser@1.2.1:
|
||||
resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==}
|
||||
@@ -8582,6 +8586,7 @@ packages:
|
||||
/reusify@1.0.4:
|
||||
resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==}
|
||||
engines: {iojs: '>=1.0.0', node: '>=0.10.0'}
|
||||
dev: true
|
||||
|
||||
/rfdc@1.3.0:
|
||||
resolution: {integrity: sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==}
|
||||
@@ -8652,6 +8657,7 @@ packages:
|
||||
hasBin: true
|
||||
optionalDependencies:
|
||||
fsevents: 2.3.2
|
||||
dev: true
|
||||
|
||||
/rrweb-cssom@0.6.0:
|
||||
resolution: {integrity: sha512-APM0Gt1KoXBz0iIkkdB/kfvGOwC4UuJFeG/c+yV7wSc7q96cG/kJ0HiYCnzivD9SB53cLV1MlHFNfOuPaadYSw==}
|
||||
@@ -8679,6 +8685,7 @@ packages:
|
||||
resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==}
|
||||
dependencies:
|
||||
queue-microtask: 1.2.3
|
||||
dev: true
|
||||
|
||||
/rxjs@7.8.1:
|
||||
resolution: {integrity: sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==}
|
||||
@@ -9251,7 +9258,6 @@ packages:
|
||||
engines: {node: '>=8'}
|
||||
dependencies:
|
||||
has-flag: 4.0.0
|
||||
dev: true
|
||||
|
||||
/supports-preserve-symlinks-flag@1.0.0:
|
||||
resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==}
|
||||
@@ -10154,6 +10160,18 @@ packages:
|
||||
xml-name-validator: 4.0.0
|
||||
dev: true
|
||||
|
||||
/wait-port@1.0.4:
|
||||
resolution: {integrity: sha512-w8Ftna3h6XSFWWc2JC5gZEgp64nz8bnaTp5cvzbJSZ53j+omktWTDdwXxEF0jM8YveviLgFWvNGrSvRHnkyHyw==}
|
||||
engines: {node: '>=10'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
chalk: 4.1.2
|
||||
commander: 9.5.0
|
||||
debug: 4.3.4
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: false
|
||||
|
||||
/walk-up-path@3.0.1:
|
||||
resolution: {integrity: sha512-9YlCL/ynK3CTlrSRrDxZvUauLzAswPCrsaCgilqFevUYpeEW0/3ScEjaa3kbW/T0ghhkEr7mv+fpjqn1Y1YuTA==}
|
||||
dev: true
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
"@nicepkg/gpt-runner-shared/browser": ["./packages/gpt-runner-shared/src/browser/index.ts"],
|
||||
"@nicepkg/gpt-runner-shared/common": ["./packages/gpt-runner-shared/src/common/index.ts"],
|
||||
"@nicepkg/gpt-runner-shared/node": ["./packages/gpt-runner-shared/src/node/index.ts"],
|
||||
|
||||
"@kvs/storage": ["./node_modules/@kvs/storage/"],
|
||||
}
|
||||
},
|
||||
"exclude": [
|
||||
|
||||
Reference in New Issue
Block a user