Ramaravind commited on
Commit
26cb589
·
verified ·
1 Parent(s): ff2617c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
app.py CHANGED
@@ -1,18 +1,18 @@
1
  import os
2
- from huggingface_hub import InferenceClient
3
 
4
- client = InferenceClient(
5
- provider="auto",
6
- api_key=os.environ["HF_API_TOKEN"],
7
- )
8
 
9
- stream = client.chat.completions.create(
10
- model="meta-llama/Llama-3.2-1B-Instruct",
11
- messages=[],
12
- temperature=0.5,
13
- top_p=0.7,
14
- stream=True,
15
- )
16
 
17
- for chunk in stream:
18
- print(chunk.choices[0].delta.content, end="")
 
 
 
 
 
1
  import os
2
+ import requests
3
 
4
+ API_URL = "https://router.huggingface.co/hf-inference/models/HuggingFaceTB/SmolLM3-3B"
5
+ headers = {
6
+ "Authorization": f"Bearer {os.environ['HF_API_TOKEN']}",
7
+ }
8
 
9
+ def query(payload):
10
+ response = requests.post(API_URL, headers=headers, json=payload)
11
+ return response.json()
 
 
 
 
12
 
13
+ response = query({
14
+ "messages": "\"Can you please let us know more details about your \"",
15
+ "model": "meta-llama/Llama-3.1-8B-Instruct:hf-inference"
16
+ })
17
+
18
+ print(response["choices"][0]["message"])