-
Notifications
You must be signed in to change notification settings - Fork 531
[Inference] Update snippets #1129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
102becc
wip: inference snippets for 3rd party providers
SBrandeis a007402
tiny tweak
julien-c 7184d1b
update this random old comment
julien-c 8aafe25
openai client compat
julien-c a941c0b
allez
julien-c aeb0731
curl snippets
julien-c bbffc28
fix
julien-c d3c2d4e
same fix
julien-c a604bb7
ok this seems to break stuff :(
julien-c 3646224
python
julien-c 4b6490a
Slowly progress
julien-c f130185
whitespace
julien-c 5b696c0
cleanup + conversational
julien-c f6bb70a
more slow progress
julien-c 204f05a
Adapt generate-snippets-fixtures script for providers (#1137)
Wauplin c4f93ae
make client mandatory?
julien-c 81c5a4f
js snippets tweaks
SBrandeis a5df834
rm installation instructions
SBrandeis 6a3fe70
format
SBrandeis e5e9ef1
Merge branch 'main' into inference/providers-snippets
SBrandeis c04b12a
ugly cast but should fix ci
SBrandeis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
14 changes: 14 additions & 0 deletions
14
packages/tasks-gen/snippets-fixtures/conversational-llm-non-stream/0.curl.together.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
curl 'https://huggingface.co/api/inference-proxy/together/v1/chat/completions' \ | ||
-H 'Authorization: Bearer api_token' \ | ||
-H 'Content-Type: application/json' \ | ||
--data '{ | ||
"model": "meta-llama/Llama-3.1-8B-Instruct", | ||
"messages": [ | ||
{ | ||
"role": "user", | ||
"content": "What is the capital of France?" | ||
} | ||
], | ||
"max_tokens": 500, | ||
"stream": false | ||
}' |
17 changes: 17 additions & 0 deletions
17
...asks-gen/snippets-fixtures/conversational-llm-non-stream/0.huggingface.js.hf-inference.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { HfInference } from "@huggingface/inference"; | ||
|
||
const client = new HfInference("api_token"); | ||
|
||
const chatCompletion = await client.chatCompletion({ | ||
model: "meta-llama/Llama-3.1-8B-Instruct", | ||
messages: [ | ||
{ | ||
role: "user", | ||
content: "What is the capital of France?" | ||
} | ||
], | ||
provider: "hf-inference", | ||
max_tokens: 500 | ||
}); | ||
|
||
console.log(chatCompletion.choices[0].message); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...sks-gen/snippets-fixtures/conversational-llm-non-stream/0.huggingface_hub.hf-inference.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from huggingface_hub import InferenceClient | ||
|
||
client = InferenceClient( | ||
provider="hf-inference", | ||
api_key="api_token" | ||
) | ||
|
||
messages = [ | ||
{ | ||
"role": "user", | ||
"content": "What is the capital of France?" | ||
} | ||
] | ||
|
||
completion = client.chat.completions.create( | ||
model="meta-llama/Llama-3.1-8B-Instruct", | ||
messages=messages, | ||
max_tokens=500 | ||
) | ||
|
||
print(completion.choices[0].message) |
5 changes: 4 additions & 1 deletion
5
...ional-llm-non-stream/0.huggingface_hub.py → ...-non-stream/0.huggingface_hub.together.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...conversational-llm-non-stream/1.openai.js → ...l-llm-non-stream/1.openai.hf-inference.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
19 changes: 19 additions & 0 deletions
19
packages/tasks-gen/snippets-fixtures/conversational-llm-non-stream/1.openai.together.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { OpenAI } from "openai"; | ||
|
||
const client = new OpenAI({ | ||
baseURL: "https://huggingface.co/api/inference-proxy/together", | ||
apiKey: "api_token" | ||
}); | ||
|
||
const chatCompletion = await client.chat.completions.create({ | ||
model: "meta-llama/Llama-3.1-8B-Instruct", | ||
messages: [ | ||
{ | ||
role: "user", | ||
content: "What is the capital of France?" | ||
} | ||
], | ||
max_tokens: 500 | ||
}); | ||
|
||
console.log(chatCompletion.choices[0].message); |
21 changes: 21 additions & 0 deletions
21
packages/tasks-gen/snippets-fixtures/conversational-llm-non-stream/1.openai.together.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from openai import OpenAI | ||
|
||
client = OpenAI( | ||
base_url="https://huggingface.co/api/inference-proxy/together", | ||
api_key="api_token" | ||
) | ||
|
||
messages = [ | ||
{ | ||
"role": "user", | ||
"content": "What is the capital of France?" | ||
} | ||
] | ||
|
||
completion = client.chat.completions.create( | ||
model="meta-llama/Llama-3.1-8B-Instruct", | ||
messages=messages, | ||
max_tokens=500 | ||
) | ||
|
||
print(completion.choices[0].message) |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
...rsational-llm-stream/0.huggingface_hub.py → ...-stream/0.huggingface_hub.hf-inference.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
...ional-vlm-non-stream/0.huggingface_hub.py → ...-stream/0.huggingface_hub.hf-inference.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.