Spaces:
Running
Running
Sync from GitHub via hub-sync
Browse files- VERSION +1 -1
- hf_inference.py +12 -0
- smolagents/hellosmol.py +17 -0
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
d41f44e05d8d4b3e36c81f2091e9f279a0ec4af5
|
hf_inference.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from huggingface_hub import InferenceClient
|
| 3 |
+
|
| 4 |
+
# Initialize client with your model and token
|
| 5 |
+
client = InferenceClient(
|
| 6 |
+
model="mistralai/Mistral-7B-Instruct-v0.3",
|
| 7 |
+
token=os.environ["HF_TOKEN"] # Recommended: set your token in env vars
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
# Example: Text Generation
|
| 11 |
+
output = client.text_generation("What is the capital of France?")
|
| 12 |
+
print(output)
|
smolagents/hellosmol.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from huggingface_hub import InferenceClient
|
| 3 |
+
|
| 4 |
+
## You need a token from https://hf.co/settings/tokens, ensure that you select 'read' as the token type. If you run this on Google Colab, you can set it up in the "settings" tab under "secrets". Make sure to call it "HF_TOKEN"
|
| 5 |
+
# HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 6 |
+
|
| 7 |
+
client = InferenceClient(model="moonshotai/Kimi-K2.5")
|
| 8 |
+
|
| 9 |
+
output = client.chat.completions.create(
|
| 10 |
+
messages=[
|
| 11 |
+
{"role": "user", "content": "The capital of France is"},
|
| 12 |
+
],
|
| 13 |
+
stream=False,
|
| 14 |
+
max_tokens=1024,
|
| 15 |
+
extra_body={'thinking': {'type': 'disabled'}},
|
| 16 |
+
)
|
| 17 |
+
print(output.choices[0].message.content)
|