MCPcopy Create free account
hub / github.com/Roy3838/Observer / FireworksAPIHandler

Class FireworksAPIHandler

api/fireworks_handler.py:13–211  ·  view source on GitHub ↗

Asynchronous handler for Fireworks AI API requests using httpx, with mapping for user-friendly model names.

Source from the content-addressed store, hash-verified

11logger = logging.getLogger("fireworks_handler")
12
13class FireworksAPIHandler(BaseAPIHandler):
14 """
15 Asynchronous handler for Fireworks AI API requests using httpx,
16 with mapping for user-friendly model names.
17 """
18 FIREWORKS_API_URL = "https://api.fireworks.ai/inference/v1/chat/completions"
19
20 def __init__(self):
21 super().__init__("fireworks")
22
23 # --- Model Mapping ---
24 # Dictionary mapping display names to actual model IDs and parameters
25 self.model_map = {
26 # Simple mapping with just two models
27 "Meta llama4-scout": {
28 "model_id": "accounts/fireworks/models/llama4-scout-instruct-basic",
29 "parameters": "109B",
30 "multimodal": True
31 },
32 # "llama4-maverick": {
33 # "model_id": "accounts/fireworks/models/llama4-maverick-instruct-basic",
34 # "parameters": "400B",
35 # "multimodal": True
36 # },
37 # "OpenAI gpt-oss-120b": {
38 # "model_id": "accounts/fireworks/models/gpt-oss-120b",
39 # "parameters": "120B",
40 # "multimodal": False
41 # },
42 # "NVIDIA nemotron Nano 2 VL": {
43 # "model_id": "accounts/fireworks/models/nemotron-nano-v2-12b-vl",
44 # "parameters": "12B",
45 # "multimodal": True
46 # },
47 }
48
49 # Define supported models for display using the pretty names from the map
50 self.models = [
51 {"name": display_name, "parameters": model_info.get("parameters", "N/A"),
52 "multimodal": model_info.get("multimodal", False), "pro": True}
53 for display_name, model_info in self.model_map.items()
54 ]
55 # --- End Model Mapping ---
56
57 self.api_key = os.environ.get("FIREWORKS_API_KEY")
58 if not self.api_key:
59 logger.error("FIREWORKS_API_KEY environment variable not set. Fireworks handler will fail.")
60
61 # Log the DISPLAY names that will be shown to the user
62 logger.info("FireworksAPIHandler registered display models: %s", [m["name"] for m in self.models])
63
64 # Base headers
65 self.base_headers = {
66 "Authorization": f"Bearer {self.api_key}" if self.api_key else "",
67 "Content-Type": "application/json",
68 "Accept": "application/json"
69 }
70

Callers 1

api_handlers.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected