UNPKG

rawi

Version:

Rawi (راوي) is the developer-friendly AI CLI that brings the power of 11 major AI providers directly to your terminal. With seamless shell integration, persistent conversations, and 200+ specialized prompt templates, Rawi transforms your command line into

1 lines 3.41 kB
{"version":3,"sources":["/home/mkabumattar/work/withrawi/rawi/dist/chunk-X5QODHIJ.cjs","../src/libs/providers/ollama/prepare-tools.ts"],"names":["prepareTools","toolChoice","tools","toolWarnings","ollamaTools","tool","type","_exhaustiveCheck","UnsupportedFunctionalityError"],"mappings":"AAAA;ACAA,4CAIO,SAESA,CAAAA,CAAa,CAC3B,UAAA,CAAAC,CAAAA,CACA,KAAA,CAAAC,CACF,CAAA,CAAiD,CAC/C,IAAMC,CAAAA,CAA6C,CAAC,CAAA,CAEpD,EAAA,CAAID,CAAAA,GAAU,KAAA,CAAA,CACZ,MAAO,CACL,KAAA,CAAO,KAAA,CAAA,CACP,YAAA,CAAAC,CACF,CAAA,CAGF,IAAMC,CAAAA,CAOA,CAAC,CAAA,CAEP,GAAA,CAAA,IAAWC,EAAAA,GAAQH,CAAAA,CACbG,CAAAA,CAAK,IAAA,GAAS,kBAAA,CAChBF,CAAAA,CAAa,IAAA,CAAK,CAAC,IAAA,CAAAE,CAAAA,CAAM,IAAA,CAAM,kBAAkB,CAAC,CAAA,CAElDD,CAAAA,CAAY,IAAA,CAAK,CACf,QAAA,CAAU,CACR,WAAA,CAAaC,CAAAA,CAAK,WAAA,CAClB,IAAA,CAAMA,CAAAA,CAAK,IAAA,CACX,UAAA,CAAYA,CAAAA,CAAK,WACnB,CAAA,CACA,IAAA,CAAM,UACR,CAAC,CAAA,CAIL,EAAA,CAAIJ,CAAAA,GAAe,KAAA,CAAA,CACjB,MAAO,CACL,KAAA,CAAOG,CAAAA,CACP,YAAA,CAAAD,CACF,CAAA,CAGF,IAAMG,CAAAA,CAAOL,CAAAA,CAAW,IAAA,CAExB,MAAA,CAAQK,CAAAA,CAAM,CACZ,IAAK,UAAA,CACL,IAAK,MAAA,CACH,MAAO,CACL,KAAA,CAAOF,CAAAA,CACP,YAAA,CAAAD,CACF,CAAA,CAEF,IAAK,MAAA,CACH,MAAO,CACL,KAAA,CAAO,KAAA,CAAA,CACP,YAAA,CAAAA,CACF,CAAA,CAEF,IAAK,MAAA,CACH,MAAO,CACL,UAAA,CAAY,CACV,QAAA,CAAU,CACR,IAAA,CAAMF,CAAAA,CAAW,QACnB,CAAA,CACA,IAAA,CAAM,UACR,CAAA,CACA,KAAA,CAAOG,CAAAA,CACP,YAAA,CAAAD,CACF,CAAA,CAEF,OAAA,CAAS,CACP,IAAMI,CAAAA,CAA2BD,CAAAA,CACjC,MAAM,IAAIE,4CAAAA,CAA8B,CACtC,aAAA,CAAe,CAAA,8BAAA,EAAiCD,CAAgB,CAAA,CAAA;AD/EqnB","file":"/home/mkabumattar/work/withrawi/rawi/dist/chunk-X5QODHIJ.cjs","sourcesContent":[null,"import {\n type LanguageModelV2,\n type LanguageModelV2CallWarning,\n UnsupportedFunctionalityError,\n} from '@ai-sdk/provider';\n\nexport function prepareTools({\n toolChoice,\n tools,\n}: Parameters<LanguageModelV2['doGenerate']>[0]) {\n const toolWarnings: LanguageModelV2CallWarning[] = [];\n\n if (tools === undefined) {\n return {\n tools: undefined,\n toolWarnings,\n };\n }\n\n const ollamaTools: {\n function: {\n description: string | undefined;\n name: string;\n parameters: unknown;\n };\n type: 'function';\n }[] = [];\n\n for (const tool of tools) {\n if (tool.type === 'provider-defined') {\n toolWarnings.push({tool, type: 'unsupported-tool'});\n } else {\n ollamaTools.push({\n function: {\n description: tool.description,\n name: tool.name,\n parameters: tool.inputSchema,\n },\n type: 'function',\n });\n }\n }\n\n if (toolChoice === undefined) {\n return {\n tools: ollamaTools,\n toolWarnings,\n };\n }\n\n const type = toolChoice.type;\n\n switch (type) {\n case 'required':\n case 'auto': {\n return {\n tools: ollamaTools,\n toolWarnings,\n };\n }\n case 'none': {\n return {\n tools: undefined,\n toolWarnings,\n };\n }\n case 'tool': {\n return {\n toolChoice: {\n function: {\n name: toolChoice.toolName,\n },\n type: 'function',\n },\n tools: ollamaTools,\n toolWarnings,\n };\n }\n default: {\n const _exhaustiveCheck: string = type;\n throw new UnsupportedFunctionalityError({\n functionality: `Unsupported tool choice type: ${_exhaustiveCheck}`,\n });\n }\n }\n}\n"]}