MCPcopy
hub / github.com/Linen-dev/linen.dev / queryThreads

Method queryThreads

packages/llm/src/typesense.ts:24–72  ·  view source on GitHub ↗
({
    query,
    apiKey,
  }: {
    query: string;
    apiKey: string;
  })

Source from the content-addressed store, hash-verified

22export default class Typesense {
23 @measure
24 static async queryThreads({
25 query,
26 apiKey,
27 }: {
28 query: string;
29 apiKey: string;
30 }) {
31 const res: ResponseT = await axios
32 .post(
33 env.TYPESENSE_URL,
34 {
35 searches: [
36 {
37 query_by: 'body',
38 collection: 'threads',
39 q: toKeywords(query),
40 page: 1,
41 highlight_fields: 'none',
42 include_fields: 'body,id',
43 // exhaustive_search: true,
44 prefix: false,
45 limit: env.CHUNKS,
46 },
47 ],
48 },
49 {
50 headers: {
51 'Content-Type': 'application/json',
52 'x-typesense-api-key': apiKey,
53 },
54 timeout: 60 * 1000,
55 }
56 )
57 .then((res) => res.data)
58 .catch((res) => console.error('%j', res));
59
60 return res.results
61 .map((r) =>
62 r.hits
63 .map((h) => {
64 return {
65 body: h.document.body,
66 id: h.document.id,
67 };
68 })
69 .flat()
70 )
71 .flat();
72 }
73}

Callers 1

predictMethod · 0.80

Calls 4

toKeywordsFunction · 0.85
mapMethod · 0.80
errorMethod · 0.65
postMethod · 0.45

Tested by

no test coverage detected