SushanthUV commited on
Commit
4cf8989
·
2 Parent(s): 426e9e3f19c3ba

Merge branch 'main' of https://github.com/DevelopedBy-Siva/flow-pilot

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .env +0 -7
  2. .env.example +0 -7
  3. .github/workflows/deploy.yml +1 -1
  4. .gitignore +23 -0
  5. README.md +1 -0
  6. backend/__pycache__/__init__.cpython-311.pyc +0 -0
  7. backend/__pycache__/__init__.cpython-312.pyc +0 -0
  8. backend/__pycache__/config.cpython-311.pyc +0 -0
  9. backend/__pycache__/config.cpython-312.pyc +0 -0
  10. backend/__pycache__/main.cpython-311.pyc +0 -0
  11. backend/__pycache__/main.cpython-312.pyc +0 -0
  12. backend/ai/__pycache__/__init__.cpython-311.pyc +0 -0
  13. backend/ai/__pycache__/__init__.cpython-312.pyc +0 -0
  14. backend/ai/__pycache__/analyzer.cpython-311.pyc +0 -0
  15. backend/ai/__pycache__/analyzer.cpython-312.pyc +0 -0
  16. backend/ai/__pycache__/classifier.cpython-311.pyc +0 -0
  17. backend/ai/__pycache__/classifier.cpython-312.pyc +0 -0
  18. backend/ai/__pycache__/client.cpython-311.pyc +0 -0
  19. backend/ai/__pycache__/client.cpython-312.pyc +0 -0
  20. backend/ai/__pycache__/composer.cpython-311.pyc +0 -0
  21. backend/ai/__pycache__/composer.cpython-312.pyc +0 -0
  22. backend/ai/__pycache__/extractor.cpython-311.pyc +0 -0
  23. backend/ai/__pycache__/extractor.cpython-312.pyc +0 -0
  24. backend/ai/__pycache__/prompts.cpython-311.pyc +0 -0
  25. backend/ai/__pycache__/prompts.cpython-312.pyc +0 -0
  26. backend/ai/__pycache__/workflow_builder.cpython-311.pyc +0 -0
  27. backend/ai/__pycache__/workflow_builder.cpython-312.pyc +0 -0
  28. backend/ai/__pycache__/workflow_suggester.cpython-311.pyc +0 -0
  29. backend/ai/__pycache__/workflow_suggester.cpython-312.pyc +0 -0
  30. backend/api/__pycache__/__init__.cpython-311.pyc +0 -0
  31. backend/api/__pycache__/__init__.cpython-312.pyc +0 -0
  32. backend/api/__pycache__/middleware.cpython-312.pyc +0 -0
  33. backend/api/__pycache__/routes.cpython-311.pyc +0 -0
  34. backend/api/__pycache__/routes.cpython-312.pyc +0 -0
  35. backend/api/routes.py +46 -15
  36. backend/config.py +1 -1
  37. backend/engine/__pycache__/__init__.cpython-311.pyc +0 -0
  38. backend/engine/__pycache__/__init__.cpython-312.pyc +0 -0
  39. backend/engine/__pycache__/compiler.cpython-311.pyc +0 -0
  40. backend/engine/__pycache__/compiler.cpython-312.pyc +0 -0
  41. backend/engine/__pycache__/executor.cpython-311.pyc +0 -0
  42. backend/engine/__pycache__/executor.cpython-312.pyc +0 -0
  43. backend/engine/__pycache__/primitives.cpython-311.pyc +0 -0
  44. backend/engine/__pycache__/primitives.cpython-312.pyc +0 -0
  45. backend/engine/__pycache__/scheduler.cpython-312.pyc +0 -0
  46. backend/engine/__pycache__/state.cpython-312.pyc +0 -0
  47. backend/engine/__pycache__/validator.cpython-311.pyc +0 -0
  48. backend/engine/__pycache__/validator.cpython-312.pyc +0 -0
  49. backend/integrations/__pycache__/__init__.cpython-311.pyc +0 -0
  50. backend/integrations/__pycache__/__init__.cpython-312.pyc +0 -0
.env DELETED
@@ -1,7 +0,0 @@
1
- AI_PROVIDER=vertex_ai
2
- ALLOW_ORIGINS=*
3
- GMAIL_POLL_SECONDS=30
4
- VERTEX_PROJECT_ID=flow-pilot-493104
5
- VERTEX_LOCATION=us-central1
6
- VERTEX_MODEL=gemini-2.5-pro
7
- GOOGLE_APPLICATION_CREDENTIALS=
 
 
 
 
 
 
 
 
.env.example DELETED
@@ -1,7 +0,0 @@
1
- AI_PROVIDER=vertex_ai
2
- ALLOW_ORIGINS=*
3
- GMAIL_POLL_SECONDS=30
4
- VERTEX_PROJECT_ID=your-gcp-project-id
5
- VERTEX_LOCATION=us-central1
6
- VERTEX_MODEL=gemini-2.5-pro
7
- GOOGLE_APPLICATION_CREDENTIALS=
 
 
 
 
 
 
 
 
.github/workflows/deploy.yml CHANGED
@@ -58,4 +58,4 @@ jobs:
58
  image: ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE }}:${{ github.sha }}
59
  flags: >-
60
  --allow-unauthenticated
61
- --set-env-vars=AI_PROVIDER=vertex_ai,VERTEX_PROJECT_ID=${{ env.PROJECT_ID }},VERTEX_LOCATION=${{ env.REGION }},VERTEX_MODEL=gemini-2.5-pro
 
58
  image: ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE }}:${{ github.sha }}
59
  flags: >-
60
  --allow-unauthenticated
61
+ --set-env-vars=AI_PROVIDER=vertex_ai,VERTEX_PROJECT_ID=${{ env.PROJECT_ID }},VERTEX_LOCATION=${{ env.REGION }},VERTEX_MODEL=gemini-2.5-flash
.gitignore ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .env
2
+ .env.local
3
+ .venv/
4
+ venv/
5
+ __pycache__/
6
+ .pytest_cache/
7
+ .mypy_cache/
8
+ .ruff_cache/
9
+ *.pyc
10
+ *.pyo
11
+ *.pyd
12
+
13
+ dist/
14
+ build/
15
+ *.egg-info/
16
+
17
+ .DS_Store
18
+ .idea/
19
+ .vscode/
20
+
21
+ flowpilot-vertex-key.json
22
+ *.pem
23
+ *.key
README.md CHANGED
@@ -74,5 +74,6 @@ The workflow builds the Docker image, pushes it to Artifact Registry, and deploy
74
  - Fill in your real Vertex values in `.env`, especially `VERTEX_PROJECT_ID` and `VERTEX_LOCATION`.
75
  - If you authenticate with `gcloud auth application-default login`, leave `GOOGLE_APPLICATION_CREDENTIALS` blank.
76
  - Only set `GOOGLE_APPLICATION_CREDENTIALS` when you have a real service account JSON path available.
 
77
  - The backend now attempts live Vertex AI calls through the `google-genai` SDK when credentials are configured.
78
  - If the SDK is missing or `VERTEX_PROJECT_ID` is still a placeholder, FlowPilot falls back to local deterministic mock logic so tests and scaffolding still work.
 
74
  - Fill in your real Vertex values in `.env`, especially `VERTEX_PROJECT_ID` and `VERTEX_LOCATION`.
75
  - If you authenticate with `gcloud auth application-default login`, leave `GOOGLE_APPLICATION_CREDENTIALS` blank.
76
  - Only set `GOOGLE_APPLICATION_CREDENTIALS` when you have a real service account JSON path available.
77
+ - The default model is `gemini-2.5-flash` for better latency and cost during iteration.
78
  - The backend now attempts live Vertex AI calls through the `google-genai` SDK when credentials are configured.
79
  - If the SDK is missing or `VERTEX_PROJECT_ID` is still a placeholder, FlowPilot falls back to local deterministic mock logic so tests and scaffolding still work.
backend/__pycache__/__init__.cpython-311.pyc DELETED
Binary file (207 Bytes)
 
backend/__pycache__/__init__.cpython-312.pyc DELETED
Binary file (157 Bytes)
 
backend/__pycache__/config.cpython-311.pyc DELETED
Binary file (2.8 kB)
 
backend/__pycache__/config.cpython-312.pyc DELETED
Binary file (2.32 kB)
 
backend/__pycache__/main.cpython-311.pyc DELETED
Binary file (1.76 kB)
 
backend/__pycache__/main.cpython-312.pyc DELETED
Binary file (1.55 kB)
 
backend/ai/__pycache__/__init__.cpython-311.pyc DELETED
Binary file (195 Bytes)
 
backend/ai/__pycache__/__init__.cpython-312.pyc DELETED
Binary file (145 Bytes)
 
backend/ai/__pycache__/analyzer.cpython-311.pyc DELETED
Binary file (4.25 kB)
 
backend/ai/__pycache__/analyzer.cpython-312.pyc DELETED
Binary file (3.82 kB)
 
backend/ai/__pycache__/classifier.cpython-311.pyc DELETED
Binary file (1.43 kB)
 
backend/ai/__pycache__/classifier.cpython-312.pyc DELETED
Binary file (1.26 kB)
 
backend/ai/__pycache__/client.cpython-311.pyc DELETED
Binary file (5.01 kB)
 
backend/ai/__pycache__/client.cpython-312.pyc DELETED
Binary file (4.49 kB)
 
backend/ai/__pycache__/composer.cpython-311.pyc DELETED
Binary file (1.99 kB)
 
backend/ai/__pycache__/composer.cpython-312.pyc DELETED
Binary file (1.74 kB)
 
backend/ai/__pycache__/extractor.cpython-311.pyc DELETED
Binary file (1.7 kB)
 
backend/ai/__pycache__/extractor.cpython-312.pyc DELETED
Binary file (1.52 kB)
 
backend/ai/__pycache__/prompts.cpython-311.pyc DELETED
Binary file (8.73 kB)
 
backend/ai/__pycache__/prompts.cpython-312.pyc DELETED
Binary file (8.61 kB)
 
backend/ai/__pycache__/workflow_builder.cpython-311.pyc DELETED
Binary file (4.86 kB)
 
backend/ai/__pycache__/workflow_builder.cpython-312.pyc DELETED
Binary file (4.36 kB)
 
backend/ai/__pycache__/workflow_suggester.cpython-311.pyc DELETED
Binary file (2.51 kB)
 
backend/ai/__pycache__/workflow_suggester.cpython-312.pyc DELETED
Binary file (2.18 kB)
 
backend/api/__pycache__/__init__.cpython-311.pyc DELETED
Binary file (197 Bytes)
 
backend/api/__pycache__/__init__.cpython-312.pyc DELETED
Binary file (147 Bytes)
 
backend/api/__pycache__/middleware.cpython-312.pyc DELETED
Binary file (439 Bytes)
 
backend/api/__pycache__/routes.cpython-311.pyc DELETED
Binary file (7.74 kB)
 
backend/api/__pycache__/routes.cpython-312.pyc DELETED
Binary file (7.17 kB)
 
backend/api/routes.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  from fastapi import APIRouter, HTTPException
2
 
3
  from backend.ai.analyzer import analyze_business_description, analyze_custom_task
@@ -24,11 +26,16 @@ from backend.storage.database import db
24
 
25
  router = APIRouter()
26
  executor = WorkflowExecutor()
 
27
 
28
 
29
  @router.post("/analyze")
30
  def analyze(request: AnalyzeRequest) -> dict:
31
- analysis = analyze_business_description(request.description)
 
 
 
 
32
  owner = db.ensure_owner(request.owner_id, request.owner_email)
33
  owner["business_description"] = request.description
34
  owner["business_analysis"] = analysis
@@ -39,30 +46,42 @@ def analyze(request: AnalyzeRequest) -> dict:
39
  @router.post("/custom-task")
40
  def custom_task(request: CustomTaskRequest) -> dict:
41
  owner = db.get_owner(request.owner_id)
42
- return analyze_custom_task(
43
- business_description=owner.get("business_description", ""),
44
- existing_workflows=db.list_workflows(request.owner_id),
45
- custom_task=request.custom_task,
46
- )
 
 
 
 
47
 
48
 
49
  @router.post("/suggest-workflows")
50
  def suggest_workflows(request: WorkflowSuggestionRequest) -> dict:
51
  owner = db.get_owner(request.owner_id)
52
- return suggest_workflow_options(
53
- task_name=request.task_name,
54
- task_description=request.task_description,
55
- category=request.category,
56
- spreadsheet_info=owner.get("spreadsheet_config", {"connected": False}),
57
- uploaded_files=db.list_data_files(request.owner_id),
58
- )
 
 
 
 
59
 
60
 
61
  @router.post("/build-workflow", response_model=BuildWorkflowResponse)
62
  def build_workflow(request: BuildWorkflowRequest) -> BuildWorkflowResponse:
63
  owner = db.get_owner(request.owner_id)
64
- workflow_json = build_workflow_definition(request=request, owner=owner)
65
- compiled = compile_workflow(workflow_json)
 
 
 
 
66
  return BuildWorkflowResponse(workflow=compiled)
67
 
68
 
@@ -125,3 +144,15 @@ def simulate_run(owner_id: str, workflow_id: str, trigger: dict) -> dict:
125
  result = executor.execute(workflow, trigger, db=db, owner_id=owner_id)
126
  db.save_execution_log(owner_id, workflow_id, trigger, result["steps"], result["outcome"], result.get("error"))
127
  return result
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+
3
  from fastapi import APIRouter, HTTPException
4
 
5
  from backend.ai.analyzer import analyze_business_description, analyze_custom_task
 
26
 
27
  router = APIRouter()
28
  executor = WorkflowExecutor()
29
+ logger = logging.getLogger(__name__)
30
 
31
 
32
  @router.post("/analyze")
33
  def analyze(request: AnalyzeRequest) -> dict:
34
+ try:
35
+ analysis = analyze_business_description(request.description)
36
+ except Exception as exc:
37
+ logger.exception("Analyze request failed")
38
+ raise HTTPException(status_code=500, detail=f"Analyze failed: {exc}") from exc
39
  owner = db.ensure_owner(request.owner_id, request.owner_email)
40
  owner["business_description"] = request.description
41
  owner["business_analysis"] = analysis
 
46
  @router.post("/custom-task")
47
  def custom_task(request: CustomTaskRequest) -> dict:
48
  owner = db.get_owner(request.owner_id)
49
+ try:
50
+ return analyze_custom_task(
51
+ business_description=owner.get("business_description", ""),
52
+ existing_workflows=db.list_workflows(request.owner_id),
53
+ custom_task=request.custom_task,
54
+ )
55
+ except Exception as exc:
56
+ logger.exception("Custom task analysis failed")
57
+ raise HTTPException(status_code=500, detail=f"Custom task analysis failed: {exc}") from exc
58
 
59
 
60
  @router.post("/suggest-workflows")
61
  def suggest_workflows(request: WorkflowSuggestionRequest) -> dict:
62
  owner = db.get_owner(request.owner_id)
63
+ try:
64
+ return suggest_workflow_options(
65
+ task_name=request.task_name,
66
+ task_description=request.task_description,
67
+ category=request.category,
68
+ spreadsheet_info=owner.get("spreadsheet_config", {"connected": False}),
69
+ uploaded_files=db.list_data_files(request.owner_id),
70
+ )
71
+ except Exception as exc:
72
+ logger.exception("Workflow suggestion failed")
73
+ raise HTTPException(status_code=500, detail=f"Workflow suggestion failed: {exc}") from exc
74
 
75
 
76
  @router.post("/build-workflow", response_model=BuildWorkflowResponse)
77
  def build_workflow(request: BuildWorkflowRequest) -> BuildWorkflowResponse:
78
  owner = db.get_owner(request.owner_id)
79
+ try:
80
+ workflow_json = build_workflow_definition(request=request, owner=owner)
81
+ compiled = compile_workflow(workflow_json)
82
+ except Exception as exc:
83
+ logger.exception("Workflow build failed")
84
+ raise HTTPException(status_code=500, detail=f"Workflow build failed: {exc}") from exc
85
  return BuildWorkflowResponse(workflow=compiled)
86
 
87
 
 
144
  result = executor.execute(workflow, trigger, db=db, owner_id=owner_id)
145
  db.save_execution_log(owner_id, workflow_id, trigger, result["steps"], result["outcome"], result.get("error"))
146
  return result
147
+
148
+
149
+ @router.get("/debug/vertex")
150
+ def debug_vertex() -> dict:
151
+ from backend.ai.client import vertex_client
152
+
153
+ try:
154
+ text = vertex_client.generate_text("Reply with exactly: Vertex debug ok")
155
+ return {"status": "ok", "response": text}
156
+ except Exception as exc:
157
+ logger.exception("Vertex debug call failed")
158
+ raise HTTPException(status_code=500, detail=f"Vertex debug failed: {exc}") from exc
backend/config.py CHANGED
@@ -16,7 +16,7 @@ class Settings(BaseModel):
16
  gmail_poll_seconds: int = int(os.getenv("GMAIL_POLL_SECONDS", "30"))
17
  vertex_project_id: str = os.getenv("VERTEX_PROJECT_ID", "your-gcp-project-id")
18
  vertex_location: str = os.getenv("VERTEX_LOCATION", "us-central1")
19
- vertex_model: str = os.getenv("VERTEX_MODEL", "gemini-2.5-pro")
20
  google_application_credentials: str = os.getenv(
21
  "GOOGLE_APPLICATION_CREDENTIALS",
22
  "",
 
16
  gmail_poll_seconds: int = int(os.getenv("GMAIL_POLL_SECONDS", "30"))
17
  vertex_project_id: str = os.getenv("VERTEX_PROJECT_ID", "your-gcp-project-id")
18
  vertex_location: str = os.getenv("VERTEX_LOCATION", "us-central1")
19
+ vertex_model: str = os.getenv("VERTEX_MODEL", "gemini-2.5-flash")
20
  google_application_credentials: str = os.getenv(
21
  "GOOGLE_APPLICATION_CREDENTIALS",
22
  "",
backend/engine/__pycache__/__init__.cpython-311.pyc DELETED
Binary file (323 Bytes)
 
backend/engine/__pycache__/__init__.cpython-312.pyc DELETED
Binary file (260 Bytes)
 
backend/engine/__pycache__/compiler.cpython-311.pyc DELETED
Binary file (483 Bytes)
 
backend/engine/__pycache__/compiler.cpython-312.pyc DELETED
Binary file (388 Bytes)
 
backend/engine/__pycache__/executor.cpython-311.pyc DELETED
Binary file (3.07 kB)
 
backend/engine/__pycache__/executor.cpython-312.pyc DELETED
Binary file (2.78 kB)
 
backend/engine/__pycache__/primitives.cpython-311.pyc DELETED
Binary file (7.47 kB)
 
backend/engine/__pycache__/primitives.cpython-312.pyc DELETED
Binary file (5.98 kB)
 
backend/engine/__pycache__/scheduler.cpython-312.pyc DELETED
Binary file (490 Bytes)
 
backend/engine/__pycache__/state.cpython-312.pyc DELETED
Binary file (627 Bytes)
 
backend/engine/__pycache__/validator.cpython-311.pyc DELETED
Binary file (1.18 kB)
 
backend/engine/__pycache__/validator.cpython-312.pyc DELETED
Binary file (945 Bytes)
 
backend/integrations/__pycache__/__init__.cpython-311.pyc DELETED
Binary file (212 Bytes)
 
backend/integrations/__pycache__/__init__.cpython-312.pyc DELETED
Binary file (162 Bytes)