Update api_clients.py
Browse files- api_clients.py +10 -20
api_clients.py
CHANGED
@@ -21,26 +21,16 @@ from web_extraction import extract_website_content, enhance_query_with_search
|
|
21 |
|
22 |
# HF Inference Client
|
23 |
HF_TOKEN = os.getenv('HF_TOKEN')
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
def get_inference_client(model_id):
|
28 |
-
"""Return an InferenceClient
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
elif model_id.startswith("fireworks/"):
|
35 |
-
return InferenceClient(
|
36 |
-
base_url="https://api.fireworks.ai/inference/v1",
|
37 |
-
api_key=FIREWORKS_API_KEY
|
38 |
-
)
|
39 |
-
else:
|
40 |
-
return InferenceClient(
|
41 |
-
model=model_id,
|
42 |
-
api_key=HF_TOKEN
|
43 |
-
)
|
44 |
|
45 |
# Tavily Search Client
|
46 |
TAVILY_API_KEY = os.getenv('TAVILY_API_KEY')
|
|
|
21 |
|
22 |
# HF Inference Client
|
23 |
HF_TOKEN = os.getenv('HF_TOKEN')
|
24 |
+
if not HF_TOKEN:
|
25 |
+
raise RuntimeError("HF_TOKEN environment variable is not set. Please set it to your Hugging Face API token.")
|
26 |
+
|
27 |
+
def get_inference_client(model_id, provider="auto"):
|
28 |
+
"""Return an InferenceClient with provider based on model_id and user selection."""
|
29 |
+
return InferenceClient(
|
30 |
+
provider=provider,
|
31 |
+
api_key=HF_TOKEN,
|
32 |
+
bill_to="huggingface"
|
33 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
# Tavily Search Client
|
36 |
TAVILY_API_KEY = os.getenv('TAVILY_API_KEY')
|