Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy Support Added #12

Merged
merged 1 commit into from
May 22, 2024
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ AI Applications generated by `create-tsi`, use LLMs hosted by T-Systems on Open
The purpose of `create-tsi` is to make the AI Application creation process easy, flexible and fast. With `create-tsi` you can generate bots, write agents and customize them for specific use cases.

### Please Note

To get started with `create-tsi`, you need a T-Systems API key. You can request trial access via [this form](https://forms.gle/1HzUGWGG12CmCnbk6).

Once you have the key, just run
Expand Down
10 changes: 10 additions & 0 deletions helpers/proxy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* Function to conditionally load the global-agent/bootstrap module */
export async function initializeGlobalAgent() {
if (process.env.GLOBAL_AGENT_HTTP_PROXY) {
/* Dynamically import global-agent/bootstrap */
await import("global-agent/bootstrap");
console.log("Proxy enabled via global-agent.");
} else {
console.log("No proxy configuration found. Continuing without proxy.");
}
}
4 changes: 4 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ import { createApp } from "./create-app";
import { getDataSources } from "./helpers/datasources";
import { getPkgManager } from "./helpers/get-pkg-manager";
import { isFolderEmpty } from "./helpers/is-folder-empty";
import { initializeGlobalAgent } from "./helpers/proxy";
import { runApp } from "./helpers/run-app";
import { getTools } from "./helpers/tools";
import { validateNpmName } from "./helpers/validate-pkg";
import packageJson from "./package.json";
import { QuestionArgs, askQuestions, onPromptState } from "./questions";

// Run the initialization function
initializeGlobalAgent();

let projectPath: string = "";

const handleSigTerm = () => process.exit(0);
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"format:write": "prettier --ignore-unknown --write .",
"dev": "ncc build ./index.ts -w -o dist/",
"build": "bash ./scripts/build.sh",
"build:win": "scripts\\build.bat",
"build:ncc": "pnpm run clean && ncc build ./index.ts -o ./dist/ --minify --no-cache --no-source-map-register",
"lint": "eslint . --ignore-pattern dist --ignore-pattern e2e/cache",
"e2e": "playwright test",
Expand All @@ -28,7 +29,8 @@
"new-version": "pnpm run build && changeset version",
"release-snapshot": "pnpm run build && changeset publish --tag snapshot",
"new-snapshot": "pnpm run build && changeset version --snapshot",
"pack-install": "bash ./scripts/pack.sh"
"pack-install": "bash ./scripts/pack.sh",
"pack-install:win": "scripts\\pack.bat"
},
"devDependencies": {
"@playwright/test": "^1.41.1",
Expand Down Expand Up @@ -67,7 +69,8 @@
"eslint-config-prettier": "^8.10.0",
"ora": "^8.0.1",
"fs-extra": "11.2.0",
"yaml": "2.4.1"
"yaml": "2.4.1",
"global-agent": "^3.0.0"
},
"engines": {
"node": ">=16.14.0"
Expand Down
69 changes: 65 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions scripts/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@echo off

rem Build dist/index.js file
pnpm run build:ncc

rem Add shebang to the top of dist/index.js
rem Note: Windows doesn't use shebangs, so this step is optional
echo // #!/usr/bin/env node > temp
type dist\index.js >> temp
move /y temp dist\index.js

rem Make dist/index.js executable (not needed on Windows)
rem chmod +x dist/index.js
3 changes: 3 additions & 0 deletions scripts/pack.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pnpm pack
for /f %%i in ('dir /b /s *.tgz') do set "package=%%i"
npm install -g %package%
6 changes: 4 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
"forceConsistentCasingInFileNames": true,
"incremental": true,
"outDir": "./lib",
"tsBuildInfoFile": "./lib/.tsbuildinfo"
"tsBuildInfoFile": "./lib/.tsbuildinfo",
"typeRoots": ["./types", "./node_modules/@types"]
},
"include": [
"create-app.ts",
"index.ts",
"./helpers",
"questions.ts",
"package.json"
"package.json",
"./types"
],
"exclude": ["dist"]
}
5 changes: 5 additions & 0 deletions types/global-agent.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*types/global-agent.d.ts */
declare module "global-agent/bootstrap" {
const anyType: any;
export = anyType;
}
Loading