Skip to content

Commit 186a347

Browse files
WauplinSBrandeis
andauthored
Generate js and curl snippets using templates (#1291)
PR built on top of #1273. This is supposed to be the last PR refactoring inference snippets :hear_no_evil: `python.ts`, `curl.ts` and `js.ts` have been merged into a single `getInferenceSnippets.ts` which handles snippet generations for all languages and all providers at once. Here is how to use it: ```ts import { snippets } from "@huggingface/inference"; const generatedSnippets = snippets.getInferenceSnippets(model, "api_token", provider, providerModelId, opts); ``` it returns a list `InferenceSnippet[]` defined as ```ts export interface InferenceSnippet { language: InferenceSnippetLanguage; // e.g. `python`, `curl`, `js` client: string; // e.g. `huggingface_hub`, `openai`, `fetch`, etc. content: string; } ``` --- ### How to review? It's hard to track all atomic changes made to the inference snippets but the best way IMO to review this PR is to check the generated snippets in the tests. Many inconsistencies in the URLs, sent parameters and indentation have been fixed. --- ### What's next? - [x] get #1273 approved - [ ] merge this one (#1291) into #1273 - [ ] merge #1273 - [ ] open PR in moon-landing to adapt to new interface (basically use `snippets.getInferenceSnippets` instead of `python.getPythonSnippets`, etc) - [ ] open PR to fix hub-docs automatic generation - [ ] fully ready for Inference Providers documentation! --------- Co-authored-by: Simon Brandeis <[email protected]>
1 parent 16ae575 commit 186a347

File tree

86 files changed

+1137
-1215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1137
-1215
lines changed

packages/inference/src/snippets/curl.ts

Lines changed: 0 additions & 177 deletions
This file was deleted.

0 commit comments

Comments
 (0)