Repository navigation
Expand file tree
/
Copy pathexceptions.py
More file actions
112 lines (102 loc) · 4.13 KB
/
Copy pathexceptions.py
File metadata and controls
112 lines (102 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Provider validation errors
GOOGLE_GLA_NO_KEY = (
"Gemini GLA provider requires api_key. "
"Set ORCHESTRATOR_API_KEY or CYPHER_API_KEY in .env file."
)
GOOGLE_VERTEX_NO_PROJECT = (
"Gemini Vertex provider requires project_id. "
"Set ORCHESTRATOR_PROJECT_ID or CYPHER_PROJECT_ID in .env file."
)
OPENAI_NO_KEY = (
"OpenAI provider requires api_key. "
"Set ORCHESTRATOR_API_KEY or CYPHER_API_KEY in .env file."
)
ANTHROPIC_NO_KEY = (
"Anthropic provider requires api_key. "
"Set ORCHESTRATOR_API_KEY or CYPHER_API_KEY in .env file."
)
AZURE_NO_KEY = "Azure OpenAI provider requires api_key. Set AZURE_API_KEY in .env file."
AZURE_NO_ENDPOINT = (
"Azure OpenAI provider requires endpoint. Set AZURE_OPENAI_ENDPOINT in .env file."
)
MINIMAX_NO_KEY = (
"MiniMax provider requires api_key. "
"Set ORCHESTRATOR_API_KEY or CYPHER_API_KEY or MINIMAX_API_KEY in .env file."
)
OLLAMA_NOT_RUNNING = (
"Ollama server not responding at {endpoint}. "
"Make sure Ollama is running: ollama serve"
)
LITELLM_NO_ENDPOINT = (
"LiteLLM provider requires endpoint. "
"Set ORCHESTRATOR_ENDPOINT or CYPHER_ENDPOINT in .env file."
)
LITELLM_NOT_RUNNING = (
"LiteLLM proxy server not responding at {endpoint}. "
"Make sure LiteLLM proxy is running and API key is valid."
)
UNKNOWN_PROVIDER = "Unknown provider '{provider}'. Available providers: {available}"
# Dependency errors
SEMANTIC_EXTRA = "Semantic search requires 'semantic' extra: uv sync --extra semantic"
# OpenAI-compatible embedding errors
OPENAI_EMBEDDING_HTTP_ERROR = (
"OpenAI-compatible embedding request failed with status {status}: {body}"
)
OPENAI_EMBEDDING_COUNT_MISMATCH = (
"OpenAI-compatible embedding response returned {got} embeddings "
"for {expected} inputs"
)
OPENAI_EMBEDDING_MALFORMED_RESPONSE = (
"OpenAI-compatible embedding response is malformed: {error}"
)
OPENAI_EMBEDDING_BAD_INDEX = (
"OpenAI-compatible embedding response has an invalid or duplicate index: {index}"
)
# Configuration errors
PROVIDER_EMPTY = "Provider name cannot be empty in 'provider:model' format."
MODEL_ID_EMPTY = "Model ID cannot be empty."
MODEL_FORMAT_INVALID = (
"Model must be specified as 'provider:model' (e.g., openai:gpt-4o)."
)
BATCH_SIZE_POSITIVE = "batch_size must be a positive integer"
CONFIG = "{role} configuration error: {error}"
MODEL_ID_UNKNOWN = "Unknown {provider} model {model_id!r}. Did you mean {suggestions}?"
MODEL_ID_UNKNOWN_NO_MATCH = (
"Unknown {provider} model {model_id!r}. Known {provider} models: {known}"
)
# Graph loading errors
GRAPH_FILE_NOT_FOUND = "Graph file not found: {path}"
FAILED_TO_LOAD_DATA = "Failed to load data from file"
NODES_NOT_LOADED = "Nodes should be loaded"
RELATIONSHIPS_NOT_LOADED = "Relationships should be loaded"
DATA_NOT_LOADED = "Data should be loaded"
# Parser errors
NO_LANGUAGES = "No Tree-sitter languages available."
# LLM errors
LLM_INIT_CYPHER = "Failed to initialize CypherGenerator: {error}"
LLM_INVALID_QUERY = "LLM did not generate a valid query. Output: {output}"
LLM_DANGEROUS_QUERY = "LLM generated a destructive Cypher query (found '{keyword}'). Query rejected: {query}"
LLM_UNBOUNDED_PATH = (
"LLM generated an unbounded variable-length path pattern "
"(e.g. [:TYPE*] or [:TYPE*N..]) which causes memory exhaustion on cyclic graphs. "
"Add an upper bound such as [:TYPE*1..6]. Query rejected: {query}"
)
LLM_DISALLOWED_PROCEDURE = (
"LLM generated a CALL to procedure '{name}' which is outside the read-only "
"MAGE allowlist. Query rejected: {query}"
)
LLM_GENERATION_FAILED = "Cypher generation failed: {error}"
LLM_INIT_ORCHESTRATOR = "Failed to initialize RAG Orchestrator: {error}"
LLM_INIT_RESEARCH = "Failed to initialize research sub-agent: {error}"
# Graph service errors
BATCH_SIZE = "batch_size must be a positive integer"
CONN = "Not connected to Memgraph."
AUTH_INCOMPLETE = (
"Both username and password are required for authentication. "
"Either provide both or neither."
)
# Access control errors (used with raise)
ACCESS_DENIED = "Access denied: Cannot access files outside the project root."
# Exception classes
class LLMGenerationError(Exception):
pass