Skip to content

Commit

Permalink
fix(gpt-runner-web): fetch github config network error
Browse files Browse the repository at this point in the history
  • Loading branch information
2214962083 committed Aug 13, 2023
1 parent 3206c88 commit eac4b48
Show file tree
Hide file tree
Showing 11 changed files with 674 additions and 916 deletions.
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@
"test:ci": "pnpm build && pnpm typecheck && pnpm lint && pnpm test"
},
"devDependencies": {
"@antfu/eslint-config": "^0.39.8",
"@antfu/eslint-config": "^0.40.2",
"@nicepkg/gpt-runner": "workspace:*",
"@nicepkg/gpt-runner-cli": "workspace:*",
"@nicepkg/gpt-runner-core": "workspace:*",
"@nicepkg/gpt-runner-shared": "workspace:*",
"@types/fs-extra": "^11.0.1",
"@types/node": "^18.16.19",
"@types/prettier": "^2.7.3",
"@types/react": "^18.2.17",
"@types/prettier": "^3.0.0",
"@types/react": "^18.2.20",
"@vitejs/plugin-legacy": "^4.1.1",
"@vitest/ui": "^0.33.0",
"@vitest/ui": "^0.34.1",
"bumpp": "^9.1.1",
"eslint": "8.45.0",
"eslint": "8.47.0",
"esno": "^0.17.0",
"execa": "^7.2.0",
"fast-glob": "^3.3.1",
Expand All @@ -46,22 +46,22 @@
"jsdom": "^22.1.0",
"lint-staged": "^13.2.3",
"msw": "1.2.3",
"pnpm": "8.6.10",
"prettier": "^3.0.0",
"pnpm": "8.6.12",
"prettier": "^3.0.1",
"react": "^18.2.0",
"rollup": "^3.26.3",
"rollup": "^3.28.0",
"semver": "^7.5.4",
"simple-git-hooks": "^2.9.0",
"taze": "^0.11.2",
"terser": "^5.19.2",
"tsup": "^7.1.0",
"tsup": "^7.2.0",
"typescript": "^5.1.6",
"unbuild": "^0.8.11",
"unplugin-auto-import": "^0.16.6",
"vite": "^4.4.7",
"vite-plugin-inspect": "^0.7.33",
"vite": "^4.4.9",
"vite-plugin-inspect": "^0.7.38",
"vite-plugin-pages": "^0.31.0",
"vitest": "^0.33.0"
"vitest": "^0.34.1"
},
"pnpm": {
"overrides": {
Expand All @@ -77,4 +77,4 @@
"eslint --cache --fix"
]
}
}
}
10 changes: 5 additions & 5 deletions packages/gpt-runner-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.mjs"
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"main": "dist/index.cjs",
Expand All @@ -48,13 +48,13 @@
"dependencies": {
"@nicepkg/gpt-runner-shared": "workspace:*",
"ignore": "^5.2.4",
"langchain": "^0.0.123",
"langchain": "^0.0.127",
"unconfig": "^0.3.10",
"uuid": "^9.0.0",
"zod": "^3.21.4"
},
"devDependencies": {
"@anthropic-ai/sdk": "^0.5.10",
"@anthropic-ai/sdk": "^0.6.0",
"openai": "^3.3.0"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ PromptTemplate.fromTemplate = function (template, { templateFormat = 'f-string',
names.add(node.name)
})
return new PromptTemplate({
inputVariables: [...names],
inputVariables: [...names] as any[],
templateFormat,
template,
...rest,
Expand Down
18 changes: 9 additions & 9 deletions packages/gpt-runner-shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,24 @@
"exports": {
".": {
"types": "./dist/common.d.ts",
"require": "./dist/common.cjs",
"import": "./dist/common.mjs"
"import": "./dist/common.mjs",
"require": "./dist/common.cjs"
},
"./*": "./*",
"./browser": {
"types": "./dist/browser.d.ts",
"require": "./dist/browser.cjs",
"import": "./dist/browser.mjs"
"import": "./dist/browser.mjs",
"require": "./dist/browser.cjs"
},
"./common": {
"types": "./dist/common.d.ts",
"require": "./dist/common.cjs",
"import": "./dist/common.mjs"
"import": "./dist/common.mjs",
"require": "./dist/common.cjs"
},
"./node": {
"types": "./dist/node.d.ts",
"require": "./dist/node.cjs",
"import": "./dist/node.mjs"
"import": "./dist/node.mjs",
"require": "./dist/node.cjs"
}
},
"main": "dist/common.cjs",
Expand Down Expand Up @@ -120,4 +120,4 @@
"@types/ip": "^1.1.0",
"express": "^4.18.2"
}
}
}
2 changes: 1 addition & 1 deletion packages/gpt-runner-shared/src/common/types/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export interface GetAppConfigReqParams {
langId?: LocaleLang
}

export type GetAppConfigResData = CurrentAppConfig
export type GetAppConfigResData = CurrentAppConfig | null

export interface MarkAsVisitedAppConfigReqParams {
types: MarkedAsVisitedType[]
Expand Down
4 changes: 2 additions & 2 deletions packages/gpt-runner-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
"@nicepkg/gpt-runner-shared": "workspace:*",
"@nicepkg/gpt-runner-web": "workspace:*",
"@types/vscode": "^1.71.0",
"@vscode/vsce": "^2.20.0",
"@vscode/vsce": "^2.20.1",
"esno": "^0.17.0",
"eventemitter3": "^5.0.1",
"execa": "^7.2.0",
Expand All @@ -159,4 +159,4 @@
"uuid": "^9.0.0",
"wait-port": "^1.0.4"
}
}
}
16 changes: 8 additions & 8 deletions packages/gpt-runner-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"@types/global-agent": "^2.1.1",
"@types/keyboardjs": "^2.5.1",
"@types/lodash-es": "^4.17.8",
"@types/react": "^18.2.18",
"@types/react": "^18.2.20",
"@types/react-dom": "^18.2.7",
"@types/react-syntax-highlighter": "^15.5.7",
"@types/uuid": "^9.0.2",
Expand All @@ -101,10 +101,10 @@
"cross-env": "^7.0.3",
"eventemitter": "^0.3.3",
"express": "^4.18.2",
"framer-motion": "^10.15.0",
"framer-motion": "^10.15.1",
"fs-extra": "^11.1.1",
"global-agent": "^3.0.0",
"i18next": "^23.4.2",
"i18next": "^23.4.4",
"i18next-browser-languagedetector": "^7.1.0",
"i18next-http-backend": "^2.2.1",
"js-base64": "^3.7.5",
Expand All @@ -113,12 +113,12 @@
"monaco-editor": "^0.41.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.10",
"react-error-boundary": "^4.0.11",
"react-hook-form": "^7.45.4",
"react-hot-toast": "^2.4.1",
"react-i18next": "^13.0.3",
"react-i18next": "^13.1.2",
"react-markdown": "^8.0.7",
"react-router-dom": "^6.14.2",
"react-router-dom": "^6.15.0",
"react-syntax-highlighter": "^15.5.0",
"react-tiny-popover": "^7.2.4",
"react-use": "^17.4.0",
Expand All @@ -127,10 +127,10 @@
"undici": "^5.23.0",
"unist-util-visit": "^5.0.0",
"uuid": "^9.0.0",
"vite": "^4.4.8",
"vite": "^4.4.9",
"vite-plugin-monaco-editor": "^1.1.0",
"vite-plugin-svgr": "^3.2.0",
"web-streams-polyfill": "^3.2.1",
"zustand": "^4.4.1"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ export const configControllers: ControllerConfig = {
const currentAppConfig = await AppConfigService.instance.getCurrentAppConfig(true)

sendSuccessResponse(res, {
data: {
...currentAppConfig,
} satisfies GetAppConfigResData,
data: currentAppConfig satisfies GetAppConfigResData,
})
},
},
Expand Down
16 changes: 14 additions & 2 deletions packages/gpt-runner-web/server/src/services/app-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ export class AppConfigService implements CurrentAppConfig {
return storage
}

async getCurrentAppConfig(safe = true): Promise<CurrentAppConfig> {
async getCurrentAppConfig(safe = true): Promise<CurrentAppConfig | null> {
if (!this.appConfig)
await this.loadAppConfig()

if (!this.appConfig)
return null

await this.updateShouldShowModal()

const result = {
Expand Down Expand Up @@ -106,7 +109,7 @@ export class AppConfigService implements CurrentAppConfig {
await this.loadAppConfig()

const { modelType, vendorName } = props
const { currentConfig } = await this.getCurrentAppConfig(false)
const { currentConfig } = await this.getCurrentAppConfig(false) || {}
let result: GetModelConfigType<T, 'secrets'> | undefined

if (currentConfig) {
Expand All @@ -128,6 +131,9 @@ export class AppConfigService implements CurrentAppConfig {
const appConfig = await this.loadAppConfigPromise
this.appConfig = appConfig || null
}
catch (e) {
console.error(e)
}
finally {
this.loadAppConfigPromise = undefined
}
Expand All @@ -137,6 +143,12 @@ export class AppConfigService implements CurrentAppConfig {
if (!this.appConfig)
await this.loadAppConfig()

if (!this.appConfig) {
this.showNotificationModal = false
this.showReleaseModal = false
return
}

const currentConfig = this.currentConfig
const storage = await this.getStorage()

Expand Down
6 changes: 3 additions & 3 deletions packages/gpt-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"exports": {
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.mjs"
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.cjs",
Expand All @@ -53,4 +53,4 @@
"dependencies": {
"@nicepkg/gpt-runner-shared": "workspace:*"
}
}
}
Loading

0 comments on commit eac4b48

Please sign in to comment.