|
1 | 1 | import type { PipelineType, WidgetType } from "@huggingface/tasks/src/pipelines.js";
|
2 | 2 | import type { ChatCompletionInputMessage, GenerationParameters } from "@huggingface/tasks/src/tasks/index.js";
|
3 | 3 | import { type InferenceSnippet, type ModelDataMinimal, getModelInputSnippet } from "@huggingface/tasks";
|
4 |
| -import type { InferenceProvider } from "../types"; |
| 4 | +import type { InferenceProvider, InferenceTask, RequestArgs } from "../types"; |
5 | 5 | import { Template } from "@huggingface/jinja";
|
6 | 6 | import { makeRequestOptionsFromResolvedModel } from "../lib/makeRequestOptions";
|
7 | 7 | import fs from "fs";
|
@@ -110,14 +110,14 @@ const snippetGenerator = (templateName: string, inputPreparationFn?: InputPrepar
|
110 | 110 | const inputs = inputPreparationFn ? inputPreparationFn(model, opts) : { inputs: getModelInputSnippet(model) };
|
111 | 111 | const request = makeRequestOptionsFromResolvedModel(
|
112 | 112 | providerModelId ?? model.id,
|
113 |
| - { accessToken: accessToken, model: providerModelId, provider: provider, ...inputs }, |
114 |
| - { chatCompletion: templateName.includes("conversational"), task: model.pipeline_tag } |
| 113 | + { accessToken: accessToken, model: providerModelId, provider: provider, ...inputs } as RequestArgs, |
| 114 | + { chatCompletion: templateName.includes("conversational"), task: model.pipeline_tag as InferenceTask } |
115 | 115 | );
|
116 | 116 |
|
117 | 117 | /// Prepare template injection data
|
118 | 118 | const params: TemplateParams = {
|
119 | 119 | accessToken,
|
120 |
| - authorizationHeader: request.info.headers?.Authorization!, |
| 120 | + authorizationHeader: (request.info.headers as Record<string, string>)?.Authorization, |
121 | 121 | baseUrl: removeSuffix(request.url, "/chat/completions"),
|
122 | 122 | fullUrl: request.url,
|
123 | 123 | inputs: {
|
|
0 commit comments