chore: update dependency
fix: fix typescript errors
This commit is contained in:
parent
62910b5879
commit
d788ca8eba
6 changed files with 292 additions and 296 deletions
|
@ -1,10 +1,10 @@
|
||||||
import { RunnableSequence, RunnableMap } from '@langchain/core/runnables';
|
import {RunnableMap, RunnableSequence} from '@langchain/core/runnables';
|
||||||
import ListLineOutputParser from '../lib/outputParsers/listLineOutputParser';
|
import ListLineOutputParser from '../lib/outputParsers/listLineOutputParser';
|
||||||
import { PromptTemplate } from '@langchain/core/prompts';
|
import {PromptTemplate} from '@langchain/core/prompts';
|
||||||
import formatChatHistoryAsString from '../utils/formatHistory';
|
import formatChatHistoryAsString from '../utils/formatHistory';
|
||||||
import { BaseMessage } from '@langchain/core/messages';
|
import {BaseMessage} from '@langchain/core/messages';
|
||||||
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
import {BaseChatModel} from '@langchain/core/language_models/chat_models';
|
||||||
import { ChatOpenAI } from '@langchain/openai';
|
import {ChatOpenAI} from '@langchain/openai';
|
||||||
|
|
||||||
const suggestionGeneratorPrompt = `
|
const suggestionGeneratorPrompt = `
|
||||||
You are an AI suggestion generator for an AI powered search engine. You will be given a conversation below. You need to generate 4-5 suggestions based on the conversation. The suggestion should be relevant to the conversation that can be used by the user to ask the chat model for more information.
|
You are an AI suggestion generator for an AI powered search engine. You will be given a conversation below. You need to generate 4-5 suggestions based on the conversation. The suggestion should be relevant to the conversation that can be used by the user to ask the chat model for more information.
|
||||||
|
@ -45,10 +45,10 @@ const createSuggestionGeneratorChain = (llm: BaseChatModel) => {
|
||||||
|
|
||||||
const generateSuggestions = (
|
const generateSuggestions = (
|
||||||
input: SuggestionGeneratorInput,
|
input: SuggestionGeneratorInput,
|
||||||
llm: BaseChatModel,
|
llm: ChatOpenAI,
|
||||||
) => {
|
) => {
|
||||||
(llm as ChatOpenAI).temperature = 0;
|
llm.temperature = 0;
|
||||||
const suggestionGeneratorChain = createSuggestionGeneratorChain(llm);
|
const suggestionGeneratorChain = createSuggestionGeneratorChain(llm as unknown as BaseChatModel);
|
||||||
return suggestionGeneratorChain.invoke(input);
|
return suggestionGeneratorChain.invoke(input);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import generateSuggestions from '../agents/suggestionGeneratorAgent';
|
import generateSuggestions from '../agents/suggestionGeneratorAgent';
|
||||||
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
import {BaseChatModel} from '@langchain/core/language_models/chat_models';
|
||||||
import { getAvailableChatModelProviders } from '../lib/providers';
|
import {getAvailableChatModelProviders} from '../lib/providers';
|
||||||
import { HumanMessage, AIMessage } from '@langchain/core/messages';
|
import {AIMessage, HumanMessage} from '@langchain/core/messages';
|
||||||
import logger from '../utils/logger';
|
import logger from '../utils/logger';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
@ -34,6 +34,7 @@ router.post('/', async (req, res) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
const suggestions = await generateSuggestions({ chat_history }, llm);
|
const suggestions = await generateSuggestions({ chat_history }, llm);
|
||||||
|
|
||||||
res.status(200).json({ suggestions: suggestions });
|
res.status(200).json({ suggestions: suggestions });
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
import { WebSocket } from 'ws';
|
import {WebSocket} from 'ws';
|
||||||
import { handleMessage } from './messageHandler';
|
import {handleMessage} from './messageHandler';
|
||||||
import {
|
import {getAvailableChatModelProviders, getAvailableEmbeddingModelProviders,} from '../lib/providers';
|
||||||
getAvailableEmbeddingModelProviders,
|
import {BaseChatModel} from '@langchain/core/language_models/chat_models';
|
||||||
getAvailableChatModelProviders,
|
import type {Embeddings} from '@langchain/core/embeddings';
|
||||||
} from '../lib/providers';
|
import type {IncomingMessage} from 'http';
|
||||||
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
||||||
import type { Embeddings } from '@langchain/core/embeddings';
|
|
||||||
import type { IncomingMessage } from 'http';
|
|
||||||
import logger from '../utils/logger';
|
import logger from '../utils/logger';
|
||||||
import { ChatOpenAI } from '@langchain/openai';
|
import {ChatOpenAI} from '@langchain/openai';
|
||||||
|
|
||||||
export const handleConnection = async (
|
export const handleConnection = async (
|
||||||
ws: WebSocket,
|
ws: WebSocket,
|
||||||
|
@ -49,7 +46,7 @@ export const handleConnection = async (
|
||||||
| BaseChatModel
|
| BaseChatModel
|
||||||
| undefined;
|
| undefined;
|
||||||
} else if (chatModelProvider == 'custom_openai') {
|
} else if (chatModelProvider == 'custom_openai') {
|
||||||
llm = new ChatOpenAI({
|
(llm as unknown as ChatOpenAI) = new ChatOpenAI({
|
||||||
modelName: chatModel,
|
modelName: chatModel,
|
||||||
openAIApiKey: searchParams.get('openAIApiKey'),
|
openAIApiKey: searchParams.get('openAIApiKey'),
|
||||||
temperature: 0.7,
|
temperature: 0.7,
|
||||||
|
|
|
@ -1,16 +1,8 @@
|
||||||
import {
|
import {BadgePercent, ChevronDown, CopyPlus, Globe, Pencil, ScanEye, SwatchBook,} from 'lucide-react';
|
||||||
BadgePercent,
|
import {cn} from '@/lib/utils';
|
||||||
ChevronDown,
|
import {Popover, Switch, Transition} from '@headlessui/react';
|
||||||
CopyPlus,
|
import {SiReddit, SiYoutube} from '@icons-pack/react-simple-icons';
|
||||||
Globe,
|
import {Fragment} from 'react';
|
||||||
Pencil,
|
|
||||||
ScanEye,
|
|
||||||
SwatchBook,
|
|
||||||
} from 'lucide-react';
|
|
||||||
import { cn } from '@/lib/utils';
|
|
||||||
import { Popover, Switch, Transition } from '@headlessui/react';
|
|
||||||
import { SiReddit, SiYoutube } from '@icons-pack/react-simple-icons';
|
|
||||||
import { Fragment } from 'react';
|
|
||||||
|
|
||||||
export const Attach = () => {
|
export const Attach = () => {
|
||||||
return (
|
return (
|
||||||
|
@ -54,9 +46,9 @@ const focusModes = [
|
||||||
description: 'Search and watch videos',
|
description: 'Search and watch videos',
|
||||||
icon: (
|
icon: (
|
||||||
<SiYoutube
|
<SiYoutube
|
||||||
className="h-5 w-auto mr-0.5"
|
className="h-5 w-auto mr-0.5"
|
||||||
onPointerEnterCapture={undefined}
|
onPointerEnter={undefined}
|
||||||
onPointerLeaveCapture={undefined}
|
onPointerLeave={undefined}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
@ -66,9 +58,9 @@ const focusModes = [
|
||||||
description: 'Search for discussions and opinions',
|
description: 'Search for discussions and opinions',
|
||||||
icon: (
|
icon: (
|
||||||
<SiReddit
|
<SiReddit
|
||||||
className="h-5 w-auto mr-0.5"
|
className="h-5 w-auto mr-0.5"
|
||||||
onPointerEnterCapture={undefined}
|
onPointerEnter={undefined}
|
||||||
onPointerLeaveCapture={undefined}
|
onPointerLeave={undefined}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@headlessui/react": "^1.7.18",
|
"@headlessui/react": "^1.7.18",
|
||||||
"@icons-pack/react-simple-icons": "^9.4.0",
|
"@icons-pack/react-simple-icons": "^9.5.0",
|
||||||
"@langchain/openai": "^0.0.25",
|
"@langchain/openai": "^0.0.25",
|
||||||
"@tailwindcss/typography": "^0.5.12",
|
"@tailwindcss/typography": "^0.5.12",
|
||||||
"clsx": "^2.1.0",
|
"clsx": "^2.1.0",
|
||||||
|
|
514
ui/yarn.lock
514
ui/yarn.lock
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue