Closed devops-snap-shoot closed 1 month ago
Hi, I am not able to reproduce this issue, can you provide more context
No worries and thanks for the mail, I update the Issue with some comment on a possible problem and proposed solution by CHATGPT, that works for my local repo. Many thanks for such a great work you are doing and keep creating!!! 😉 Marc
El sáb, 6 jul 2024 a la(s) 5:31 a.m., ItzCrazyKns @.***) escribió:
Hi, I am not able to reproduce this issue, can you provide more context
— Reply to this email directly, view it on GitHub https://github.com/ItzCrazyKns/Perplexica/issues/246#issuecomment-2211719659, or unsubscribe https://github.com/notifications/unsubscribe-auth/BCFWMDRBSJLCOMA42AJZK33ZK62PVAVCNFSM6AAAAABKN56CL2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJRG4YTSNRVHE . You are receiving this because you authored the thread.Message ID: @.***>
Describe the bug there is shown a Conversion of type error as follow To Reproduce Steps to reproduce the behavior:
Expected behavior A clear and concise description of what you expected to happen.
Additional context error log: npm run build
src/agents/suggestionGeneratorAgent.ts:50:4 - error TS2352: Conversion of type 'BaseChatModel<BaseLanguageModelCallOptions, BaseMessageChunk>' to type 'ChatOpenAI' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
Type 'BaseChatModel<BaseLanguageModelCallOptions, BaseMessageChunk>' is missing the following properties from type 'ChatOpenAI': temperature, topP, frequencyPenalty, presencePenalty, and 11 more.
50 (llm as ChatOpenAI).temperature = 0;
Found 2 errors in 2 files.
Errors Files 1 src/agents/suggestionGeneratorAgent.ts:50 1 src/websocket/connectionManager.ts:52 a I ask GPT and told me :
The errors you're encountering are related to TypeScript type incompatibilities between
BaseChatModel
andChatOpenAI
. These errors suggest that the typesBaseChatModel
andChatOpenAI
are not compatible and that explicit type conversions might be necessary.Here's a step-by-step guide to resolve these errors:
Step 1: Examine the Type Definitions
First, let's understand the type definitions and why these errors occur. The error messages indicate that
BaseChatModel
andChatOpenAI
do not share the same properties. To fix this, you need to ensure that the type conversion is handled correctly.Step 2: Update the Type Conversions
Fix in
src/agents/suggestionGeneratorAgent.ts
:Update the type conversion to use
unknown
first, and then cast toChatOpenAI
to avoid the type incompatibility error.suggested Fix in
src/websocket/connectionManager.ts
:import type { BaseLanguageModelCallOptions } from '@langchain/core/language_models/base'; Update the llm type:
let llm: BaseChatModel | undefined;
Update the casting for ChatOpenAI:
} else if (chatModelProvider === 'custom_openai') { llm = new ChatOpenAI({ modelName: chatModel, openAIApiKey: searchParams.get('openAIApiKey') || '', temperature: 0.7, configuration: { baseURL: searchParams.get('openAIBaseURL') || '', }, }) as unknown as BaseChatModel;
}