Upload 61 files
Browse files- app/api/routes/ingest.py +5 -1
- app/main.py +1 -2
app/api/routes/ingest.py
CHANGED
|
@@ -46,12 +46,14 @@ def search_wikipedia(q: str, limit: int = 10):
|
|
| 46 |
async def import_from_wikipedia(
|
| 47 |
title: str,
|
| 48 |
entity_type: str = "person",
|
|
|
|
| 49 |
auto_extract: bool = True,
|
| 50 |
db: Session = Depends(get_db)
|
| 51 |
):
|
| 52 |
"""
|
| 53 |
Importa uma entidade da Wikipedia
|
| 54 |
entity_type: person, organization, location
|
|
|
|
| 55 |
auto_extract: Se True, usa LLM para extrair entidades relacionadas
|
| 56 |
"""
|
| 57 |
# Check if entity already exists
|
|
@@ -76,8 +78,9 @@ async def import_from_wikipedia(
|
|
| 76 |
if not data:
|
| 77 |
raise HTTPException(status_code=404, detail="Article not found on Wikipedia")
|
| 78 |
|
| 79 |
-
# Create main entity
|
| 80 |
entity = Entity(**data)
|
|
|
|
| 81 |
db.add(entity)
|
| 82 |
db.commit()
|
| 83 |
db.refresh(entity)
|
|
@@ -123,6 +126,7 @@ async def import_from_wikipedia(
|
|
| 123 |
latitude=lat,
|
| 124 |
longitude=lng,
|
| 125 |
event_date=event_date,
|
|
|
|
| 126 |
properties={"role": ext_entity.role, "aliases": ext_entity.aliases, "extracted_from": title}
|
| 127 |
)
|
| 128 |
db.add(new_ent)
|
|
|
|
| 46 |
async def import_from_wikipedia(
|
| 47 |
title: str,
|
| 48 |
entity_type: str = "person",
|
| 49 |
+
project_id: Optional[str] = None,
|
| 50 |
auto_extract: bool = True,
|
| 51 |
db: Session = Depends(get_db)
|
| 52 |
):
|
| 53 |
"""
|
| 54 |
Importa uma entidade da Wikipedia
|
| 55 |
entity_type: person, organization, location
|
| 56 |
+
project_id: ID do projeto para associar a entidade
|
| 57 |
auto_extract: Se True, usa LLM para extrair entidades relacionadas
|
| 58 |
"""
|
| 59 |
# Check if entity already exists
|
|
|
|
| 78 |
if not data:
|
| 79 |
raise HTTPException(status_code=404, detail="Article not found on Wikipedia")
|
| 80 |
|
| 81 |
+
# Create main entity with project_id
|
| 82 |
entity = Entity(**data)
|
| 83 |
+
entity.project_id = project_id
|
| 84 |
db.add(entity)
|
| 85 |
db.commit()
|
| 86 |
db.refresh(entity)
|
|
|
|
| 126 |
latitude=lat,
|
| 127 |
longitude=lng,
|
| 128 |
event_date=event_date,
|
| 129 |
+
project_id=project_id,
|
| 130 |
properties={"role": ext_entity.role, "aliases": ext_entity.aliases, "extracted_from": title}
|
| 131 |
)
|
| 132 |
db.add(new_ent)
|
app/main.py
CHANGED
|
@@ -8,7 +8,7 @@ from contextlib import asynccontextmanager
|
|
| 8 |
|
| 9 |
from app.config import settings
|
| 10 |
from app.core.database import init_db
|
| 11 |
-
from app.api.routes import entities, relationships, events, search, ingest, analyze, graph, research, chat, investigate, dados_publicos, timeline
|
| 12 |
|
| 13 |
|
| 14 |
@asynccontextmanager
|
|
@@ -62,7 +62,6 @@ app.include_router(chat.router, prefix="/api/v1")
|
|
| 62 |
app.include_router(investigate.router, prefix="/api/v1")
|
| 63 |
app.include_router(dados_publicos.router, prefix="/api/v1")
|
| 64 |
app.include_router(timeline.router, prefix="/api/v1")
|
| 65 |
-
app.include_router(projects.router, prefix="/api/v1")
|
| 66 |
|
| 67 |
|
| 68 |
@app.get("/")
|
|
|
|
| 8 |
|
| 9 |
from app.config import settings
|
| 10 |
from app.core.database import init_db
|
| 11 |
+
from app.api.routes import entities, relationships, events, search, ingest, analyze, graph, research, chat, investigate, dados_publicos, timeline
|
| 12 |
|
| 13 |
|
| 14 |
@asynccontextmanager
|
|
|
|
| 62 |
app.include_router(investigate.router, prefix="/api/v1")
|
| 63 |
app.include_router(dados_publicos.router, prefix="/api/v1")
|
| 64 |
app.include_router(timeline.router, prefix="/api/v1")
|
|
|
|
| 65 |
|
| 66 |
|
| 67 |
@app.get("/")
|