Skip to content

Commit

Permalink
fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
hanouticelina committed Nov 15, 2024
1 parent cf0ac82 commit 435a3fe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 4 additions & 4 deletions docs/api-inference/tasks/chat-completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ To use the Python client, see `huggingface_hub`'s [package reference](https://hu

<js>
```js
# With huggingface_hub client
// With huggingface_hub client

import { HfInference } from "@huggingface/inference"

Expand All @@ -162,7 +162,7 @@ for await (const chunk of stream) {
}
}

# With openai client
// With openai client

import { OpenAI } from "openai"

Expand Down Expand Up @@ -315,7 +315,7 @@ To use the Python client, see `huggingface_hub`'s [package reference](https://hu

<js>
```js
# With huggingface_hub client
// With huggingface_hub client

import { HfInference } from "@huggingface/inference"

Expand Down Expand Up @@ -353,7 +353,7 @@ for await (const chunk of stream) {
}
}

# With openai client
// With openai client

import { OpenAI } from "openai"

Expand Down
11 changes: 9 additions & 2 deletions scripts/api-inference/scripts/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
};
Expand Down

0 comments on commit 435a3fe

Please sign in to comment.