MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / generateQuestionAnswerSummary

Method generateQuestionAnswerSummary

packages/llm/src/langchain.ts:228–265  ·  view source on GitHub ↗
(input: string[])

Source from the content-addressed store, hash-verified

226
227 @measure
228 static async generateQuestionAnswerSummary(input: string[]) {
229 const chatPrompt = ChatPromptTemplate.fromMessages([
230 [
231 'system',
232 `You are a helpful assistant that extract the question and the answer from given context.
233 Also you will summarize the context.
234 Output MUST BE in json format within "question", "answer", "summary",
235 "confidence_question", "confidence_answer" and "confidence_summary" keys.
236 Your response must have a confidence interval from 0 to 100 (avoid decimals) for each json key.`,
237 ],
238 ['human', '{text}'],
239 ]);
240 const chainB = new LLMChain({
241 prompt: chatPrompt,
242 llm: model,
243 });
244 try {
245 const resB = await chainB.call({
246 text: input.join('\n'),
247 });
248 try {
249 return JSON.parse(String(resB.text).trim()) as {
250 question: string;
251 answer: string;
252 summary: string;
253 confidence_question: number;
254 confidence_answer: number;
255 confidence_summary: number;
256 };
257 } catch (error) {
258 console.error('parse failure: ' + error, resB);
259 return null;
260 }
261 } catch (error) {
262 console.error('api failure: ' + error);
263 return null;
264 }
265 }
266
267 @measure
268 static async generateEmbeddings(input: string[]) {

Callers

nothing calls this directly

Calls 1

errorMethod · 0.65

Tested by

no test coverage detected