Spaces:
Building
Building
Update llm_spark.py
Browse files- llm_spark.py +7 -7
llm_spark.py
CHANGED
@@ -4,7 +4,7 @@ Spark LLM Implementation
|
|
4 |
import httpx
|
5 |
from typing import Dict, List, Any
|
6 |
from llm_interface import LLMInterface
|
7 |
-
from
|
8 |
|
9 |
class SparkLLM(LLMInterface):
|
10 |
"""Spark LLM integration"""
|
@@ -14,7 +14,7 @@ class SparkLLM(LLMInterface):
|
|
14 |
self.spark_endpoint = spark_endpoint.rstrip("/")
|
15 |
self.spark_token = spark_token
|
16 |
self.provider_variant = provider_variant
|
17 |
-
|
18 |
|
19 |
async def generate(self, system_prompt: str, user_input: str, context: List[Dict]) -> str:
|
20 |
"""Generate response from Spark LLM"""
|
@@ -49,10 +49,10 @@ class SparkLLM(LLMInterface):
|
|
49 |
result = response.json()
|
50 |
return result.get("model_answer", "")
|
51 |
except httpx.TimeoutException:
|
52 |
-
|
53 |
raise
|
54 |
except Exception as e:
|
55 |
-
|
56 |
raise
|
57 |
|
58 |
async def startup(self, project_config: Dict) -> bool:
|
@@ -71,7 +71,7 @@ class SparkLLM(LLMInterface):
|
|
71 |
break
|
72 |
|
73 |
if not version:
|
74 |
-
|
75 |
return False
|
76 |
|
77 |
llm_config = version.get("llm", {})
|
@@ -90,10 +90,10 @@ class SparkLLM(LLMInterface):
|
|
90 |
headers=headers
|
91 |
)
|
92 |
response.raise_for_status()
|
93 |
-
|
94 |
return True
|
95 |
except Exception as e:
|
96 |
-
|
97 |
return False
|
98 |
|
99 |
def get_provider_name(self) -> str:
|
|
|
4 |
import httpx
|
5 |
from typing import Dict, List, Any
|
6 |
from llm_interface import LLMInterface
|
7 |
+
from logger import log_info, log_error, log_warning, log_debug
|
8 |
|
9 |
class SparkLLM(LLMInterface):
|
10 |
"""Spark LLM integration"""
|
|
|
14 |
self.spark_endpoint = spark_endpoint.rstrip("/")
|
15 |
self.spark_token = spark_token
|
16 |
self.provider_variant = provider_variant
|
17 |
+
log_info(f"π SparkLLM initialized with endpoint: {self.spark_endpoint}")
|
18 |
|
19 |
async def generate(self, system_prompt: str, user_input: str, context: List[Dict]) -> str:
|
20 |
"""Generate response from Spark LLM"""
|
|
|
49 |
result = response.json()
|
50 |
return result.get("model_answer", "")
|
51 |
except httpx.TimeoutException:
|
52 |
+
log_warning("β±οΈ Spark request timed out")
|
53 |
raise
|
54 |
except Exception as e:
|
55 |
+
log_error("β Spark error", e)
|
56 |
raise
|
57 |
|
58 |
async def startup(self, project_config: Dict) -> bool:
|
|
|
71 |
break
|
72 |
|
73 |
if not version:
|
74 |
+
log_info("β No published version found")
|
75 |
return False
|
76 |
|
77 |
llm_config = version.get("llm", {})
|
|
|
90 |
headers=headers
|
91 |
)
|
92 |
response.raise_for_status()
|
93 |
+
log_info("β
Spark startup successful")
|
94 |
return True
|
95 |
except Exception as e:
|
96 |
+
log_error("β Spark startup failed", e)
|
97 |
return False
|
98 |
|
99 |
def get_provider_name(self) -> str:
|