Skip to content

Commit e322c3a

Browse files
committed
Fixed
1 parent ecc9643 commit e322c3a

2 files changed

Lines changed: 30 additions & 3 deletions

File tree

src/shared/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ export const pearAiModels = {
821821
contextWindow: 64000,
822822
// Default values for required fields, but actual values will be inherited from underlying model
823823
supportsPromptCache: true,
824-
supportsImages: true,
824+
supportsImages: false,
825825
supportsComputerUse: false,
826826
// Base pricing
827827
inputPrice: 0.014,

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
import { McpServer, McpTool } from "../../../../src/shared/mcp"
1515
import { findLast } from "../../../../src/shared/array"
1616
import { combineApiRequests } from "../../../../src/shared/combineApiRequests"
17+
import { ModelInfo, pearAiDefaultModelId, pearAiDefaultModelInfo, PEARAI_URL } from "../../../../src/shared/api"
1718
import { combineCommandSequences } from "../../../../src/shared/combineCommandSequences"
1819
import { getApiMetrics } from "../../../../src/shared/getApiMetrics"
1920
import { useExtensionState } from "../../context/ExtensionStateContext"
@@ -463,9 +464,35 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
463464
startNewTask()
464465
}, [startNewTask])
465466

467+
const [pearAiModels, setPearAiModels] = useState<Record<string, ModelInfo>>({
468+
[pearAiDefaultModelId]: pearAiDefaultModelInfo,
469+
})
470+
471+
// Fetch PearAI models when provider is selected
472+
useEffect(() => {
473+
if (apiConfiguration?.apiProvider === "pearai") {
474+
const fetchPearAiModels = async () => {
475+
try {
476+
const res = await fetch(`${PEARAI_URL}/getPearAIAgentModels`)
477+
if (!res.ok) throw new Error("Failed to fetch models")
478+
const config = await res.json()
479+
480+
if (config.models && Object.keys(config.models).length > 0) {
481+
console.log("Models successfully loaded from server")
482+
setPearAiModels(config.models)
483+
}
484+
} catch (error) {
485+
console.error("Error fetching PearAI models:", error)
486+
}
487+
}
488+
489+
fetchPearAiModels()
490+
}
491+
}, [apiConfiguration?.apiProvider])
492+
466493
const { selectedModelInfo } = useMemo(() => {
467-
return normalizeApiConfiguration(apiConfiguration)
468-
}, [apiConfiguration])
494+
return normalizeApiConfiguration(apiConfiguration, pearAiModels)
495+
}, [apiConfiguration, pearAiModels])
469496

470497
const selectImages = useCallback(() => {
471498
vscode.postMessage({ type: "selectImages" })

0 commit comments

Comments
 (0)