( parameters: Record<string, any>, key: string, allowObjects: boolean = false, )
| 160 | } |
| 161 | |
| 162 | export function getParam( |
| 163 | parameters: Record<string, any>, |
| 164 | key: string, |
| 165 | allowObjects: boolean = false, |
| 166 | ): any { |
| 167 | let out: any = undefined; |
| 168 | if (key in parameters) out = parameters[key]; |
| 169 | if (!out) { |
| 170 | // Sometimes (rarely) the AI replaces hyphens with underscores. This is a hacky fix |
| 171 | const found = Object.keys(parameters).find( |
| 172 | (k) => k.replaceAll("-", "_") === key.replaceAll("-", "_"), |
| 173 | ); |
| 174 | if (found) out = parameters[found]; |
| 175 | } |
| 176 | if (out === undefined) return undefined; |
| 177 | if (allowObjects && typeof out === "object") { |
| 178 | return JSON.stringify(out); |
| 179 | } |
| 180 | return out; |
| 181 | } |
| 182 | |
| 183 | export function deduplicateChunks( |
| 184 | chunks: SimilaritySearchResult[], |
no outgoing calls
no test coverage detected