refactor(graph): remove hardcoded ZEP checks, use get_graph_config_errors; add embed/small LLM env docs
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c074136a87
commit
09935e53a0
|
|
@ -56,6 +56,19 @@ ZEP_API_KEY="<la-teva-zep-api-key>"
|
||||||
# NEO4J_URI="bolt://<ip-o-hostname>:7687"
|
# NEO4J_URI="bolt://<ip-o-hostname>:7687"
|
||||||
# NEO4J_USER="neo4j"
|
# NEO4J_USER="neo4j"
|
||||||
# NEO4J_PASSWORD="<contrasenya-neo4j>"
|
# NEO4J_PASSWORD="<contrasenya-neo4j>"
|
||||||
|
# GRAPHITI_BATCH_SIZE="10" # chunks per crida bulk; més alt = més ràpid però més paral·lelisme LLM
|
||||||
|
|
||||||
|
# --- Embedding LLM (usat per Graphiti per a indexació vectorial) ---
|
||||||
|
# Si no s'estableix, fa fallback a LLM_API_KEY / LLM_BASE_URL.
|
||||||
|
# LLM_EMBED_API_KEY="<la-teva-embed-api-key>"
|
||||||
|
# LLM_EMBED_BASE_URL="https://<recurs>.cognitiveservices.azure.com/openai/deployments/<embed-deployment>/embeddings?api-version=2024-05-01-preview"
|
||||||
|
# LLM_EMBED_MODEL_NAME="text-embedding-3-small"
|
||||||
|
|
||||||
|
# --- Small/fast LLM (usat per Graphiti per a reranking i tasques lleugeres) ---
|
||||||
|
# Si no s'estableix, fa fallback a LLM_API_KEY / LLM_BASE_URL / LLM_MODEL_NAME.
|
||||||
|
# LLM_SMALL_API_KEY="<la-teva-small-api-key>"
|
||||||
|
# LLM_SMALL_BASE_URL="https://<recurs>.cognitiveservices.azure.com/openai/deployments/<small-model>/chat/completions?api-version=2024-05-01-preview"
|
||||||
|
# LLM_SMALL_MODEL_NAME="gpt-4o-mini"
|
||||||
|
|
||||||
# ── Simulació OASIS (valors per defecte recomanats) ───────────────────────────
|
# ── Simulació OASIS (valors per defecte recomanats) ───────────────────────────
|
||||||
OASIS_DEFAULT_MAX_ROUNDS="10"
|
OASIS_DEFAULT_MAX_ROUNDS="10"
|
||||||
|
|
|
||||||
|
|
@ -284,9 +284,7 @@ def build_graph():
|
||||||
logger.info("=== Starting graph build ===")
|
logger.info("=== Starting graph build ===")
|
||||||
|
|
||||||
# Check configuration
|
# Check configuration
|
||||||
errors = []
|
errors = Config.get_graph_config_errors()
|
||||||
if not Config.ZEP_API_KEY:
|
|
||||||
errors.append(t('api.zepApiKeyMissing'))
|
|
||||||
if errors:
|
if errors:
|
||||||
logger.error(f"Configuration error: {errors}")
|
logger.error(f"Configuration error: {errors}")
|
||||||
return jsonify({
|
return jsonify({
|
||||||
|
|
@ -387,7 +385,7 @@ def build_graph():
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create graph builder service
|
# Create graph builder service
|
||||||
builder = GraphBuilderService(api_key=Config.ZEP_API_KEY)
|
builder = GraphBuilderService()
|
||||||
|
|
||||||
# Split into chunks
|
# Split into chunks
|
||||||
task_manager.update_task(
|
task_manager.update_task(
|
||||||
|
|
@ -437,10 +435,11 @@ def build_graph():
|
||||||
progress=15
|
progress=15
|
||||||
)
|
)
|
||||||
|
|
||||||
|
batch_size = Config.GRAPHITI_BATCH_SIZE if Config.GRAPH_BACKEND == 'graphiti' else 3
|
||||||
episode_uuids = builder.add_text_batches(
|
episode_uuids = builder.add_text_batches(
|
||||||
graph_id,
|
graph_id,
|
||||||
chunks,
|
chunks,
|
||||||
batch_size=3,
|
batch_size=batch_size,
|
||||||
progress_callback=add_progress_callback
|
progress_callback=add_progress_callback
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -572,13 +571,7 @@ def get_graph_data(graph_id: str):
|
||||||
Get graph data (nodes and edges)
|
Get graph data (nodes and edges)
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if not Config.ZEP_API_KEY:
|
builder = GraphBuilderService()
|
||||||
return jsonify({
|
|
||||||
"success": False,
|
|
||||||
"error": t('api.zepApiKeyMissing')
|
|
||||||
}), 500
|
|
||||||
|
|
||||||
builder = GraphBuilderService(api_key=Config.ZEP_API_KEY)
|
|
||||||
graph_data = builder.get_graph_data(graph_id)
|
graph_data = builder.get_graph_data(graph_id)
|
||||||
|
|
||||||
return jsonify({
|
return jsonify({
|
||||||
|
|
@ -600,13 +593,7 @@ def delete_graph(graph_id: str):
|
||||||
Delete a Zep graph
|
Delete a Zep graph
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if not Config.ZEP_API_KEY:
|
builder = GraphBuilderService()
|
||||||
return jsonify({
|
|
||||||
"success": False,
|
|
||||||
"error": t('api.zepApiKeyMissing')
|
|
||||||
}), 500
|
|
||||||
|
|
||||||
builder = GraphBuilderService(api_key=Config.ZEP_API_KEY)
|
|
||||||
builder.delete_graph(graph_id)
|
builder.delete_graph(graph_id)
|
||||||
|
|
||||||
return jsonify({
|
return jsonify({
|
||||||
|
|
|
||||||
|
|
@ -57,12 +57,6 @@ def get_graph_entities(graph_id: str):
|
||||||
enrich: whether to fetch related edge info (default true)
|
enrich: whether to fetch related edge info (default true)
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if not Config.ZEP_API_KEY:
|
|
||||||
return jsonify({
|
|
||||||
"success": False,
|
|
||||||
"error": t('api.zepApiKeyMissing')
|
|
||||||
}), 500
|
|
||||||
|
|
||||||
entity_types_str = request.args.get('entity_types', '')
|
entity_types_str = request.args.get('entity_types', '')
|
||||||
entity_types = [t.strip() for t in entity_types_str.split(',') if t.strip()] if entity_types_str else None
|
entity_types = [t.strip() for t in entity_types_str.split(',') if t.strip()] if entity_types_str else None
|
||||||
enrich = request.args.get('enrich', 'true').lower() == 'true'
|
enrich = request.args.get('enrich', 'true').lower() == 'true'
|
||||||
|
|
@ -94,12 +88,6 @@ def get_graph_entities(graph_id: str):
|
||||||
def get_entity_detail(graph_id: str, entity_uuid: str):
|
def get_entity_detail(graph_id: str, entity_uuid: str):
|
||||||
"""Get detailed information about a single entity"""
|
"""Get detailed information about a single entity"""
|
||||||
try:
|
try:
|
||||||
if not Config.ZEP_API_KEY:
|
|
||||||
return jsonify({
|
|
||||||
"success": False,
|
|
||||||
"error": t('api.zepApiKeyMissing')
|
|
||||||
}), 500
|
|
||||||
|
|
||||||
reader = ZepEntityReader()
|
reader = ZepEntityReader()
|
||||||
entity = reader.get_entity_with_context(graph_id, entity_uuid)
|
entity = reader.get_entity_with_context(graph_id, entity_uuid)
|
||||||
|
|
||||||
|
|
@ -127,12 +115,6 @@ def get_entity_detail(graph_id: str, entity_uuid: str):
|
||||||
def get_entities_by_type(graph_id: str, entity_type: str):
|
def get_entities_by_type(graph_id: str, entity_type: str):
|
||||||
"""Get all entities of a specified type"""
|
"""Get all entities of a specified type"""
|
||||||
try:
|
try:
|
||||||
if not Config.ZEP_API_KEY:
|
|
||||||
return jsonify({
|
|
||||||
"success": False,
|
|
||||||
"error": t('api.zepApiKeyMissing')
|
|
||||||
}), 500
|
|
||||||
|
|
||||||
enrich = request.args.get('enrich', 'true').lower() == 'true'
|
enrich = request.args.get('enrich', 'true').lower() == 'true'
|
||||||
|
|
||||||
reader = ZepEntityReader()
|
reader = ZepEntityReader()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue