From 435a3fe3df8c1120250d9af8cb21f54b98a33cae Mon Sep 17 00:00:00 2001 From: Celina Hanouti Date: Fri, 15 Nov 2024 15:44:34 +0100 Subject: [PATCH] fix comment --- docs/api-inference/tasks/chat-completion.md | 8 ++++---- scripts/api-inference/scripts/generate.ts | 11 +++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/docs/api-inference/tasks/chat-completion.md b/docs/api-inference/tasks/chat-completion.md index 59e16a307..3f4c9b369 100644 --- a/docs/api-inference/tasks/chat-completion.md +++ b/docs/api-inference/tasks/chat-completion.md @@ -135,7 +135,7 @@ To use the Python client, see `huggingface_hub`'s [package reference](https://hu ```js -# With huggingface_hub client +// With huggingface_hub client import { HfInference } from "@huggingface/inference" @@ -162,7 +162,7 @@ for await (const chunk of stream) { } } -# With openai client +// With openai client import { OpenAI } from "openai" @@ -315,7 +315,7 @@ To use the Python client, see `huggingface_hub`'s [package reference](https://hu ```js -# With huggingface_hub client +// With huggingface_hub client import { HfInference } from "@huggingface/inference" @@ -353,7 +353,7 @@ for await (const chunk of stream) { } } -# With openai client +// With openai client import { OpenAI } from "openai" diff --git a/scripts/api-inference/scripts/generate.ts b/scripts/api-inference/scripts/generate.ts index 71e0c5fb5..2b4805912 100644 --- a/scripts/api-inference/scripts/generate.ts +++ b/scripts/api-inference/scripts/generate.ts @@ -106,10 +106,17 @@ const formatSnippets = (result: snippets.types.InferenceSnippet | snippets.types return snippet.content; } - // For multiple snippets, add comments between them + // Get the appropriate comment + const commentPrefix = { + 'py': '#', + 'js': '//', + 'bash': '#' + }[language] || '#'; + + // Show the snippet for each client return result .map(snippet => - `# With ${snippet.client || defaultClient} client\n\n${snippet.content}` + `${commentPrefix} With ${snippet.client || defaultClient} client\n\n${snippet.content}` ) .join('\n\n'); };