|
3 | 3 | RunnableMap, |
4 | 4 | RunnableLambda, |
5 | 5 | } from '@langchain/core/runnables'; |
6 | | -import { ChatPromptTemplate, PromptTemplate } from '@langchain/core/prompts'; |
| 6 | +import { ChatPromptTemplate } from '@langchain/core/prompts'; |
7 | 7 | import formatChatHistoryAsString from '../utils/formatHistory'; |
8 | 8 | import { BaseMessage } from '@langchain/core/messages'; |
9 | 9 | import { StringOutputParser } from '@langchain/core/output_parsers'; |
@@ -45,40 +45,31 @@ const createVideoSearchChain = (llm: BaseChatModel) => { |
45 | 45 | ['system', videoSearchChainPrompt], |
46 | 46 | [ |
47 | 47 | 'user', |
48 | | - '<conversation>\n</conversation>\n<follow_up>\nHow does a car work?\n</follow_up>' |
49 | | - ], |
50 | | - [ |
51 | | - 'assistant', |
52 | | - '<query>How does a car work?</query>' |
| 48 | + '<conversation>\n</conversation>\n<follow_up>\nHow does a car work?\n</follow_up>', |
53 | 49 | ], |
| 50 | + ['assistant', '<query>How does a car work?</query>'], |
54 | 51 | [ |
55 | 52 | 'user', |
56 | | - '<conversation>\n</conversation>\n<follow_up>\nWhat is the theory of relativity?\n</follow_up>' |
57 | | - ], |
58 | | - [ |
59 | | - 'assistant', |
60 | | - '<query>Theory of relativity</query>' |
| 53 | + '<conversation>\n</conversation>\n<follow_up>\nWhat is the theory of relativity?\n</follow_up>', |
61 | 54 | ], |
| 55 | + ['assistant', '<query>Theory of relativity</query>'], |
62 | 56 | [ |
63 | 57 | 'user', |
64 | | - '<conversation>\n</conversation>\n<follow_up>\nHow does an AC work?\n</follow_up>' |
65 | | - ], |
66 | | - [ |
67 | | - 'assistant', |
68 | | - '<query>AC working</query>' |
| 58 | + '<conversation>\n</conversation>\n<follow_up>\nHow does an AC work?\n</follow_up>', |
69 | 59 | ], |
| 60 | + ['assistant', '<query>AC working</query>'], |
70 | 61 | [ |
71 | 62 | 'user', |
72 | | - '<conversation>{chat_history}</conversation>\n<follow_up>\n{query}\n</follow_up>' |
73 | | - ] |
| 63 | + '<conversation>{chat_history}</conversation>\n<follow_up>\n{query}\n</follow_up>', |
| 64 | + ], |
74 | 65 | ]), |
75 | 66 | llm, |
76 | 67 | strParser, |
77 | 68 | RunnableLambda.from(async (input: string) => { |
78 | 69 | const queryParser = new LineOutputParser({ |
79 | | - key: 'query' |
| 70 | + key: 'query', |
80 | 71 | }); |
81 | | - return (await queryParser.parse(input)); |
| 72 | + return await queryParser.parse(input); |
82 | 73 | }), |
83 | 74 | RunnableLambda.from(async (input: string) => { |
84 | 75 | const res = await searchSearxng(input, { |
|
0 commit comments