MCPcopy Create free account
hub / github.com/Noumena-Network/code / queryWithModel

Function queryWithModel

src/services/api/claude.ts:3327–3375  ·  view source on GitHub ↗
({
  systemPrompt = asSystemPrompt([]),
  userPrompt,
  outputFormat,
  signal,
  options,
}: {
  systemPrompt: SystemPrompt
  userPrompt: string
  outputFormat?: BetaJSONOutputFormat
  signal: AbortSignal
  options: QueryWithModelOptions
})

Source from the content-addressed store, hash-verified

3325 * betas, and headers - unlike direct API calls.
3326 */
3327export async function queryWithModel({
3328 systemPrompt = asSystemPrompt([]),
3329 userPrompt,
3330 outputFormat,
3331 signal,
3332 options,
3333}: {
3334 systemPrompt: SystemPrompt
3335 userPrompt: string
3336 outputFormat?: BetaJSONOutputFormat
3337 signal: AbortSignal
3338 options: QueryWithModelOptions
3339}): Promise<AssistantMessage> {
3340 const result = await withVCR(
3341 [
3342 createUserMessage({
3343 content: systemPrompt.map(text => ({ type: 'text', text })),
3344 }),
3345 createUserMessage({
3346 content: userPrompt,
3347 }),
3348 ],
3349 async () => {
3350 const messages = [
3351 createUserMessage({
3352 content: userPrompt,
3353 }),
3354 ]
3355
3356 const result = await queryModelWithoutStreaming({
3357 messages,
3358 systemPrompt,
3359 thinkingConfig: { type: 'disabled' },
3360 tools: [],
3361 signal,
3362 options: {
3363 ...options,
3364 enablePromptCaching: options.enablePromptCaching ?? false,
3365 outputFormat,
3366 async getToolPermissionContext() {
3367 return getEmptyToolPermissionContext()
3368 },
3369 },
3370 })
3371 return [result]
3372 },
3373 )
3374 return result[0]! as AssistantMessage
3375}
3376
3377// Non-streaming requests have a 10min max per the docs:
3378// long-request API error docs

Callers 3

summarizeTranscriptChunkFunction · 0.85
extractFacetsFromAPIFunction · 0.85
generateSectionInsightFunction · 0.85

Calls 4

asSystemPromptFunction · 0.85
withVCRFunction · 0.85
createUserMessageFunction · 0.50

Tested by

no test coverage detected