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

Class FireworksAPIHandler

api/fireworks_handler.py:13–218  ·  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 "Kimi K2.5": {
28 "model_id": "accounts/fireworks/models/kimi-k2p5",
29 "parameters": "1.02T",
30 "multimodal": True,
31 "pro": True
32 },
33 "Qwen3.6 Plus": {
34 "model_id": "accounts/fireworks/models/qwen3p6-plus",
35 "parameters": "36B",
36 "multimodal": True,
37 "pro": True
38 },
39 # "llama4-maverick": {
40 # "model_id": "accounts/fireworks/models/llama4-maverick-instruct-basic",
41 # "parameters": "400B",
42 # "multimodal": True
43 # },
44 # "OpenAI gpt-oss-120b": {
45 # "model_id": "accounts/fireworks/models/gpt-oss-120b",
46 # "parameters": "120B",
47 # "multimodal": False
48 # },
49 # "NVIDIA nemotron Nano 2 VL": {
50 # "model_id": "accounts/fireworks/models/nemotron-nano-v2-12b-vl",
51 # "parameters": "12B",
52 # "multimodal": True
53 # },
54 }
55
56 # Define supported models for display using the pretty names from the map
57 self.models = [
58 {"name": display_name, "parameters": model_info.get("parameters", "N/A"),
59 "multimodal": model_info.get("multimodal", False), "pro": model_info.get("pro", False)}
60 for display_name, model_info in self.model_map.items()
61 ]
62 # --- End Model Mapping ---
63
64 self.api_key = os.environ.get("FIREWORKS_API_KEY")
65 if not self.api_key:
66 logger.error("FIREWORKS_API_KEY environment variable not set. Fireworks handler will fail.")
67
68 # Log the DISPLAY names that will be shown to the user
69 logger.info("FireworksAPIHandler registered display models: %s", [m["name"] for m in self.models])
70

Callers 1

api_handlers.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected