-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create local client node to process jobs queue
- Loading branch information
1 parent
b246ef7
commit 8453766
Showing
58 changed files
with
923 additions
and
312 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
name: API - Pull Request | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- daily | ||
- release/alpha | ||
- master | ||
paths: | ||
- ".github/workflows/**" | ||
- "packages/@liexp/**/src/**" | ||
- "services/ai-bot/**" | ||
|
||
jobs: | ||
install: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: ./.github/actions/install-deps | ||
with: | ||
hash: ${{ hashFiles('**/pnpm-lock.yaml') }} | ||
|
||
build-packages: | ||
runs-on: ubuntu-latest | ||
needs: [install] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: ./.github/actions/install-deps | ||
with: | ||
hash: ${{ hashFiles('**/pnpm-lock.yaml') }} | ||
|
||
- uses: ./.github/actions/build-packages | ||
with: | ||
hash: ${{ github.sha }} | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
needs: [install, build-packages] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: ./.github/actions/install-deps | ||
with: | ||
hash: ${{ hashFiles('**/pnpm-lock.yaml') }} | ||
|
||
- uses: ./.github/actions/build-packages | ||
with: | ||
hash: ${{ github.sha }} | ||
|
||
- name: Lint code | ||
run: pnpm ai-bot lint | ||
|
||
build: | ||
needs: [install, build-packages] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: ./.github/actions/install-deps | ||
with: | ||
hash: ${{ hashFiles('**/pnpm-lock.yaml') }} | ||
|
||
- uses: ./.github/actions/build-packages | ||
with: | ||
hash: ${{ github.sha }} | ||
|
||
- name: Run migrations | ||
run: pnpm ai-bot build | ||
|
||
# docker_build: | ||
# if: ${{ github.head_ref == 'release/alpha' }} | ||
# needs: [install, build-packages, lint, build] | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - uses: actions/checkout@v4 | ||
|
||
# - uses: ./.github/actions/install-deps | ||
# with: | ||
# hash: ${{ hashFiles('**/pnpm-lock.yaml') }} | ||
|
||
# - name: Log in to registry | ||
# uses: docker/login-action@v3 | ||
# with: | ||
# registry: ghcr.io | ||
# username: ${{ github.actor }} | ||
# password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# - name: Set up Docker Buildx | ||
# uses: docker/setup-buildx-action@v3 | ||
|
||
# - name: Build API image | ||
# uses: docker/build-push-action@v5 | ||
# with: | ||
# context: . | ||
# file: ./api.Dockerfile | ||
# push: false | ||
# tags: ${{ env.API_IMAGE_NAME }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
"author": "Andrea Ascari <[email protected]>", | ||
"scripts": { | ||
"admin-web": "pnpm --filter 'admin-web'", | ||
"ai-bot": "pnpm --filter 'ai-bot'", | ||
"api": "pnpm --filter 'api'", | ||
"backend": "pnpm --filter '@liexp/backend'", | ||
"build": "pnpm -r run build", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
API_URL=http://api.liexp.dev/v1 | ||
LOCALAI_URL=http://localai.liexp.dev:8080/v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import baseEslintConfig from "@liexp/core/lib/eslint/base.config.js"; | ||
import tseslint from "typescript-eslint"; | ||
|
||
const eslintConfig = tseslint.config(...baseEslintConfig, { | ||
files: ["bin/**/*.ts", "src/**/*.ts"], | ||
ignores: ["**/*.d.ts"], | ||
languageOptions: { | ||
parserOptions: { | ||
project: ["./tsconfig.json"], | ||
tsconfigRootDir: import.meta.dirname, | ||
}, | ||
}, | ||
}); | ||
|
||
export default eslintConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "@liexp/ai-bot", | ||
"version": "1.0.0", | ||
"bin": { | ||
"liexp-ai-bot": "./build/liexp-ai-bot.js" | ||
}, | ||
"type": "module", | ||
"imports": { | ||
"#common/*": "./build/common/*", | ||
"#flows/*": "./build/flows/*" | ||
}, | ||
"scripts": { | ||
"typecheck": "tsc --noEmit", | ||
"bin:run": "node ./build/bin/cli.js", | ||
"build": "tsc -b tsconfig.build.json", | ||
"clean": "rm -rf build", | ||
"dev": "node --watch build/run.js", | ||
"dev:alpha": "DOTENV_CONFIG_PATH=.env.alpha pnpm dev", | ||
"docker:dev": "pnpm dev", | ||
"docker:worker-dev": "node --watch build/worker/index.js", | ||
"lint": "eslint src", | ||
"start": "node build/run.js" | ||
}, | ||
"dependencies": { | ||
"@liexp/core": "workspace:*", | ||
"@liexp/shared": "workspace:*", | ||
"@liexp/backend": "workspace:*", | ||
"fp-ts": "^2", | ||
"io-ts": "^2" | ||
}, | ||
"devDependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e -x | ||
|
||
pnpm pack | ||
|
||
npm install -g liexp-ai-bot-*.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { type FSError } from "@liexp/backend/lib/providers/fs/fs.provider.js"; | ||
import { type PuppeteerError } from "@liexp/backend/lib/providers/puppeteer.provider.js"; | ||
import { type APIError } from "@liexp/shared/lib/io/http/Error/APIError.js"; | ||
import { type PDFError } from "@liexp/shared/lib/providers/pdf/pdf.provider.js"; | ||
import { IOError } from "ts-shared/lib/errors.js"; | ||
|
||
export type ApiBotError = | ||
| PuppeteerError | ||
| PDFError | ||
| FSError | ||
| APIError | ||
| IOError; | ||
|
||
export const toApiBotError = (e: unknown): ApiBotError => { | ||
if (e instanceof IOError) { | ||
return e; | ||
} | ||
|
||
return new IOError("Unknown error", { | ||
kind: "ServerError", | ||
meta: [e, JSON.stringify(e)], | ||
status: "Unknown Error", | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { | ||
type LoggerContext, | ||
type FSClientContext, | ||
type HTTPProviderContext, | ||
type PDFProviderContext, | ||
} from "@liexp/backend/lib/context/index.js"; | ||
import { type LangchainProvider } from "@liexp/backend/lib/providers/ai/langchain.provider.js"; | ||
import { type Endpoints } from "@liexp/shared/lib/endpoints/index.js"; | ||
import { type EndpointsRESTClient } from "@liexp/shared/lib/providers/EndpointsRESTClient/types.js"; | ||
import { type APIRESTClient } from "@liexp/shared/lib/providers/api-rest.provider.js"; | ||
|
||
interface EndpointsRESTClientContext { | ||
endpointsRESTClient: EndpointsRESTClient<Endpoints>; | ||
} | ||
|
||
interface APIRESTClientContext { | ||
apiRESTClient: APIRESTClient; | ||
} | ||
|
||
interface LangchainContext { | ||
langchain: LangchainProvider; | ||
} | ||
|
||
export type ClientContext = LangchainContext & | ||
HTTPProviderContext & | ||
PDFProviderContext & | ||
APIRESTClientContext & | ||
EndpointsRESTClientContext & | ||
FSClientContext & | ||
LoggerContext; |
Oops, something went wrong.