Skip to content

Commit 0016193

Browse files
committed
At least the connection is working
1 parent aec2c72 commit 0016193

2 files changed

Lines changed: 41 additions & 48 deletions

File tree

src/core/webview/ClineProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
423423
`style-src ${webview.cspSource} 'unsafe-inline' https://* http://${localServerUrl} http://0.0.0.0:${localPort}`,
424424
`img-src ${webview.cspSource} data:`,
425425
`script-src 'unsafe-eval' https://* http://${localServerUrl} http://0.0.0.0:${localPort} 'nonce-${nonce}'`,
426-
`connect-src https://* ws://${localServerUrl} ws://0.0.0.0:${localPort} http://${localServerUrl} http://0.0.0.0:${localPort}`,
426+
`connect-src https://* ws://${localServerUrl} ws://0.0.0.0:${localPort} http://${localServerUrl} http://0.0.0.0:${localPort} http://localhost:8000 http://0.0.0.0:8000`,
427427
]
428428

429429
return /*html*/ `

src/shared/api.ts

Lines changed: 40 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -792,14 +792,27 @@ export const unboundDefaultModelInfo: ModelInfo = {
792792
}
793793
// CHANGE AS NEEDED FOR TESTING
794794
// PROD:
795-
export const PEARAI_URL = "https://stingray-app-gb2an.ondigitalocean.app/pearai-server-api2/integrations/cline"
795+
// export const PEARAI_URL = "https://stingray-app-gb2an.ondigitalocean.app/pearai-server-api2/integrations/cline"
796796
// DEV:
797-
// export const PEARAI_URL = "http://localhost:8000/integrations/cline"
797+
export const PEARAI_URL = "http://localhost:8000/integrations/cline"
798798

799799
// PearAI
800800
export type PearAiModelId = keyof typeof pearAiModels
801801
export const pearAiDefaultModelId: PearAiModelId = "pearai-model"
802-
export const pearAiModels = {
802+
export const pearAiDefaultModelInfo: ModelInfo = {
803+
maxTokens: 8192,
804+
contextWindow: 64000,
805+
supportsImages: false,
806+
supportsPromptCache: true,
807+
inputPrice: 0.014,
808+
outputPrice: 0.28,
809+
cacheWritesPrice: 0.27,
810+
cacheReadsPrice: 0.07,
811+
description:
812+
"DeepSeek-V3 achieves a significant breakthrough in inference speed over previous models. It tops the leaderboard among open-source models and rivals the most advanced closed-source models globally.",
813+
}
814+
815+
export let pearAiModels = {
803816
"pearai-model": {
804817
maxTokens: 8192,
805818
contextWindow: 64000,
@@ -812,48 +825,28 @@ export const pearAiModels = {
812825
description:
813826
"DeepSeek-V3 achieves a significant breakthrough in inference speed over previous models. It tops the leaderboard among open-source models and rivals the most advanced closed-source models globally.",
814827
},
815-
"claude-3-5-sonnet-20241022": {
816-
maxTokens: 8192,
817-
contextWindow: 200000,
818-
supportsImages: true,
819-
supportsComputerUse: true,
820-
supportsPromptCache: true,
821-
inputPrice: 3.0,
822-
outputPrice: 15.0,
823-
cacheWritesPrice: 3.75,
824-
cacheReadsPrice: 0.3,
825-
},
826-
"claude-3-5-haiku-20241022": {
827-
maxTokens: 8192,
828-
contextWindow: 200000,
829-
supportsImages: false,
830-
supportsPromptCache: true,
831-
inputPrice: 1.0,
832-
outputPrice: 5.0,
833-
cacheWritesPrice: 1.25,
834-
cacheReadsPrice: 0.1,
835-
},
836-
"deepseek-chat": {
837-
maxTokens: 8192,
838-
contextWindow: 64000,
839-
supportsImages: false,
840-
supportsPromptCache: true,
841-
inputPrice: 0.014,
842-
outputPrice: 0.28,
843-
cacheWritesPrice: 0.27,
844-
cacheReadsPrice: 0.07,
845-
description:
846-
"DeepSeek-V3 achieves a significant breakthrough in inference speed over previous models. It tops the leaderboard among open-source models and rivals the most advanced closed-source models globally.",
847-
},
848-
"deepseek-reasoner": {
849-
maxTokens: 8192,
850-
contextWindow: 64000,
851-
supportsImages: false,
852-
supportsPromptCache: true,
853-
inputPrice: 0.55,
854-
outputPrice: 2.19,
855-
cacheWritesPrice: 0.55,
856-
cacheReadsPrice: 0.14,
857-
description: "DeepSeek-R1 achieves performance comparable to OpenAI-o1 across math, code, and reasoning tasks.",
858-
},
859828
} as const satisfies Record<string, ModelInfo>
829+
830+
// Initialize models with a Promise
831+
export let modelsInitialized: Promise<Record<string, ModelInfo>>
832+
833+
modelsInitialized = (async () => {
834+
try {
835+
const res = await fetch(`${PEARAI_URL}/getPearAIAgentModels`)
836+
if (!res.ok) throw new Error("Failed to fetch models")
837+
const config = await res.json()
838+
839+
if (config.models && Object.keys(config.models).length > 0) {
840+
console.log("Models successfully loaded from server")
841+
console.dir(config.models)
842+
pearAiModels = config.models
843+
return config.models
844+
} else {
845+
console.log("Using default models (no models returned from server)")
846+
return { [pearAiDefaultModelId]: pearAiDefaultModelInfo }
847+
}
848+
} catch (error) {
849+
console.error("Error fetching PearAI models:", error)
850+
return { [pearAiDefaultModelId]: pearAiDefaultModelInfo }
851+
}
852+
})()

0 commit comments

Comments
 (0)