| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | from typing import Optional | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-22 10:41:34 +08:00
										 |  |  | class LLMError(ValueError): | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |     """Base class for all LLM exceptions.""" | 
					
						
							| 
									
										
										
										
											2024-09-10 17:00:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |     description: Optional[str] = None | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def __init__(self, description: Optional[str] = None) -> None: | 
					
						
							|  |  |  |         self.description = description | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class LLMBadRequestError(LLMError): | 
					
						
							|  |  |  |     """Raised when the LLM returns bad request.""" | 
					
						
							| 
									
										
										
										
											2024-09-10 17:00:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |     description = "Bad Request" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-22 10:41:34 +08:00
										 |  |  | class ProviderTokenNotInitError(ValueError): | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |     """
 | 
					
						
							|  |  |  |     Custom exception raised when the provider token is not initialized. | 
					
						
							|  |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2024-09-10 17:00:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |     description = "Provider Token Not Init" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-17 00:14:19 +08:00
										 |  |  |     def __init__(self, *args, **kwargs): | 
					
						
							|  |  |  |         self.description = args[0] if args else self.description | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-22 10:41:34 +08:00
										 |  |  | class QuotaExceededError(ValueError): | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |     """
 | 
					
						
							|  |  |  |     Custom exception raised when the quota for a provider has been exceeded. | 
					
						
							|  |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2024-09-10 17:00:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |     description = "Quota Exceeded" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-22 10:41:34 +08:00
										 |  |  | class AppInvokeQuotaExceededError(ValueError): | 
					
						
							| 
									
										
										
										
											2024-07-10 13:31:35 +00:00
										 |  |  |     """
 | 
					
						
							|  |  |  |     Custom exception raised when the quota for an app has been exceeded. | 
					
						
							|  |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2024-09-10 17:00:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-10 13:31:35 +00:00
										 |  |  |     description = "App Invoke Quota Exceeded" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-22 10:41:34 +08:00
										 |  |  | class ModelCurrentlyNotSupportError(ValueError): | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |     """
 | 
					
						
							|  |  |  |     Custom exception raised when the model not support | 
					
						
							|  |  |  |     """
 | 
					
						
							| 
									
										
										
										
											2024-09-10 17:00:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-15 08:51:32 +08:00
										 |  |  |     description = "Model Currently Not Support" | 
					
						
							| 
									
										
										
										
											2024-08-26 19:36:44 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-22 10:41:34 +08:00
										 |  |  | class InvokeRateLimitError(ValueError): | 
					
						
							| 
									
										
										
										
											2024-08-26 19:36:44 +08:00
										 |  |  |     """Raised when the Invoke returns rate limit error.""" | 
					
						
							| 
									
										
										
										
											2024-09-10 17:00:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-26 19:36:44 +08:00
										 |  |  |     description = "Rate Limit Error" |