nao-core 0.0.11__py3-none-any.whl → 0.0.14__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. nao_core/__init__.py +1 -1
  2. nao_core/bin/db.sqlite +0 -0
  3. nao_core/bin/fastapi/main.py +102 -0
  4. nao_core/bin/migrations-postgres/0000_supreme_cable.sql +85 -0
  5. nao_core/bin/migrations-postgres/meta/0000_snapshot.json +610 -0
  6. nao_core/bin/migrations-postgres/meta/_journal.json +13 -0
  7. nao_core/bin/migrations-sqlite/0000_cloudy_squirrel_girl.sql +85 -0
  8. nao_core/bin/migrations-sqlite/meta/0000_snapshot.json +590 -0
  9. nao_core/bin/migrations-sqlite/meta/_journal.json +13 -0
  10. nao_core/bin/nao-chat-server +0 -0
  11. nao_core/bin/public/assets/_chatId-z5gRlor1.js +1 -0
  12. nao_core/bin/public/assets/chat-messages-DUR3D342.js +1 -0
  13. nao_core/bin/public/assets/index-BDlcD_HE.js +1 -0
  14. nao_core/bin/public/assets/index-Bc7icYyJ.css +1 -0
  15. nao_core/bin/public/assets/index-CGg3ZQH6.js +49 -0
  16. nao_core/bin/public/assets/login-D87n9R5V.js +1 -0
  17. nao_core/bin/public/assets/signinForm-9PY1Lvqj.js +1 -0
  18. nao_core/bin/public/assets/signup-B7NC1g08.js +1 -0
  19. nao_core/bin/public/github-icon.svg +19 -0
  20. nao_core/bin/public/google-icon.svg +2 -0
  21. nao_core/bin/public/index.html +2 -2
  22. nao_core/commands/chat.py +67 -25
  23. nao_core/commands/init.py +3 -3
  24. nao_core/commands/sync.py +274 -44
  25. nao_core/config/__init__.py +13 -0
  26. nao_core/{config.py → config/base.py} +4 -66
  27. nao_core/config/databases/__init__.py +29 -0
  28. nao_core/config/databases/base.py +72 -0
  29. nao_core/config/databases/bigquery.py +42 -0
  30. nao_core/config/llm/__init__.py +16 -0
  31. {nao_core-0.0.11.dist-info → nao_core-0.0.14.dist-info}/METADATA +3 -1
  32. nao_core-0.0.14.dist-info/RECORD +39 -0
  33. nao_core/bin/public/assets/index-BSxC58nD.js +0 -36
  34. nao_core/bin/public/assets/index-Dh3br3Ia.js +0 -13
  35. nao_core/bin/public/assets/index-heKLHGGE.css +0 -1
  36. nao_core-0.0.11.dist-info/RECORD +0 -20
  37. {nao_core-0.0.11.dist-info → nao_core-0.0.14.dist-info}/WHEEL +0 -0
  38. {nao_core-0.0.11.dist-info → nao_core-0.0.14.dist-info}/entry_points.txt +0 -0
  39. {nao_core-0.0.11.dist-info → nao_core-0.0.14.dist-info}/licenses/LICENSE +0 -0
nao_core/__init__.py CHANGED
@@ -1,2 +1,2 @@
1
1
  # nao Core CLI package
2
- __version__ = "0.0.11"
2
+ __version__ = "0.0.14"
nao_core/bin/db.sqlite CHANGED
Binary file
@@ -0,0 +1,102 @@
1
+ from fastapi import FastAPI, HTTPException
2
+ from fastapi.middleware.cors import CORSMiddleware
3
+ from pydantic import BaseModel
4
+ import uvicorn
5
+ import os
6
+ import sys
7
+ from pathlib import Path
8
+
9
+ cli_path = Path(__file__).parent.parent.parent / "cli"
10
+ sys.path.insert(0, str(cli_path))
11
+
12
+ from nao_core.config import NaoConfig
13
+
14
+ port = int(os.environ.get("PORT", 8005))
15
+
16
+ app = FastAPI()
17
+
18
+ app.add_middleware(
19
+ CORSMiddleware,
20
+ allow_origins=["*"],
21
+ allow_methods=["*"],
22
+ allow_headers=["*"],
23
+ )
24
+
25
+
26
+ class ExecuteSQLRequest(BaseModel):
27
+ sql: str
28
+ nao_project_folder: str
29
+ database_id: str | None = None
30
+
31
+
32
+ class ExecuteSQLResponse(BaseModel):
33
+ data: list[dict]
34
+ row_count: int
35
+ columns: list[str]
36
+
37
+
38
+ @app.post("/execute_sql", response_model=ExecuteSQLResponse)
39
+ async def execute_sql(request: ExecuteSQLRequest):
40
+ try:
41
+ # Load the nao config from the project folder
42
+ project_path = Path(request.nao_project_folder)
43
+ config = NaoConfig.try_load(project_path)
44
+
45
+ if config is None:
46
+ raise HTTPException(
47
+ status_code=400,
48
+ detail=f"Could not load nao_config.yaml from {request.nao_project_folder}"
49
+ )
50
+
51
+ if len(config.databases) == 0:
52
+ raise HTTPException(
53
+ status_code=400,
54
+ detail="No databases configured in nao_config.yaml"
55
+ )
56
+
57
+ # Determine which database to use
58
+ if len(config.databases) == 1:
59
+ db_config = config.databases[0]
60
+ elif request.database_id:
61
+ # Find the database by name
62
+ db_config = next(
63
+ (db for db in config.databases if db.name == request.database_id),
64
+ None
65
+ )
66
+ if db_config is None:
67
+ available_databases = [db.name for db in config.databases]
68
+ raise HTTPException(
69
+ status_code=400,
70
+ detail={
71
+ "message": f"Database '{request.database_id}' not found",
72
+ "available_databases": available_databases
73
+ }
74
+ )
75
+ else:
76
+ # Multiple databases and no database_id specified
77
+ available_databases = [db.name for db in config.databases]
78
+ raise HTTPException(
79
+ status_code=400,
80
+ detail={
81
+ "message": "Multiple databases configured. Please specify database_id.",
82
+ "available_databases": available_databases
83
+ }
84
+ )
85
+
86
+ connection = db_config.connect()
87
+ result = connection.sql(request.sql)
88
+
89
+ df = result.to_pandas()
90
+ data = df.to_dict(orient="records")
91
+
92
+ return ExecuteSQLResponse(
93
+ data=data,
94
+ row_count=len(data),
95
+ columns=df.columns.tolist(),
96
+ )
97
+ except Exception as e:
98
+ raise HTTPException(status_code=500, detail=str(e))
99
+
100
+
101
+ if __name__ == "__main__":
102
+ uvicorn.run("main:app", host="0.0.0.0", port=port, reload=True)
@@ -0,0 +1,85 @@
1
+ CREATE TABLE "account" (
2
+ "id" text PRIMARY KEY NOT NULL,
3
+ "account_id" text NOT NULL,
4
+ "provider_id" text NOT NULL,
5
+ "user_id" text NOT NULL,
6
+ "access_token" text,
7
+ "refresh_token" text,
8
+ "id_token" text,
9
+ "access_token_expires_at" timestamp,
10
+ "refresh_token_expires_at" timestamp,
11
+ "scope" text,
12
+ "password" text,
13
+ "created_at" timestamp DEFAULT now() NOT NULL,
14
+ "updated_at" timestamp NOT NULL
15
+ );
16
+ --> statement-breakpoint
17
+ CREATE TABLE "chat_message" (
18
+ "id" text PRIMARY KEY NOT NULL,
19
+ "conversation_id" text NOT NULL,
20
+ "role" text NOT NULL,
21
+ "content" text NOT NULL,
22
+ "created_at" timestamp DEFAULT now() NOT NULL
23
+ );
24
+ --> statement-breakpoint
25
+ CREATE TABLE "conversation" (
26
+ "id" text PRIMARY KEY NOT NULL,
27
+ "user_id" text NOT NULL,
28
+ "title" text DEFAULT 'New Conversation' NOT NULL,
29
+ "created_at" timestamp DEFAULT now() NOT NULL,
30
+ "updated_at" timestamp DEFAULT now() NOT NULL
31
+ );
32
+ --> statement-breakpoint
33
+ CREATE TABLE "session" (
34
+ "id" text PRIMARY KEY NOT NULL,
35
+ "expires_at" timestamp NOT NULL,
36
+ "token" text NOT NULL,
37
+ "created_at" timestamp DEFAULT now() NOT NULL,
38
+ "updated_at" timestamp NOT NULL,
39
+ "ip_address" text,
40
+ "user_agent" text,
41
+ "user_id" text NOT NULL,
42
+ CONSTRAINT "session_token_unique" UNIQUE("token")
43
+ );
44
+ --> statement-breakpoint
45
+ CREATE TABLE "tool_call" (
46
+ "id" text PRIMARY KEY NOT NULL,
47
+ "message_id" text NOT NULL,
48
+ "tool_call_id" text NOT NULL,
49
+ "tool_name" text NOT NULL,
50
+ "input" jsonb NOT NULL,
51
+ "output" jsonb,
52
+ "created_at" timestamp DEFAULT now() NOT NULL
53
+ );
54
+ --> statement-breakpoint
55
+ CREATE TABLE "user" (
56
+ "id" text PRIMARY KEY NOT NULL,
57
+ "name" text NOT NULL,
58
+ "email" text NOT NULL,
59
+ "email_verified" boolean DEFAULT false NOT NULL,
60
+ "image" text,
61
+ "created_at" timestamp DEFAULT now() NOT NULL,
62
+ "updated_at" timestamp DEFAULT now() NOT NULL,
63
+ CONSTRAINT "user_email_unique" UNIQUE("email")
64
+ );
65
+ --> statement-breakpoint
66
+ CREATE TABLE "verification" (
67
+ "id" text PRIMARY KEY NOT NULL,
68
+ "identifier" text NOT NULL,
69
+ "value" text NOT NULL,
70
+ "expires_at" timestamp NOT NULL,
71
+ "created_at" timestamp DEFAULT now() NOT NULL,
72
+ "updated_at" timestamp DEFAULT now() NOT NULL
73
+ );
74
+ --> statement-breakpoint
75
+ ALTER TABLE "account" ADD CONSTRAINT "account_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
76
+ ALTER TABLE "chat_message" ADD CONSTRAINT "chat_message_conversation_id_conversation_id_fk" FOREIGN KEY ("conversation_id") REFERENCES "public"."conversation"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
77
+ ALTER TABLE "conversation" ADD CONSTRAINT "conversation_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
78
+ ALTER TABLE "session" ADD CONSTRAINT "session_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
79
+ ALTER TABLE "tool_call" ADD CONSTRAINT "tool_call_message_id_chat_message_id_fk" FOREIGN KEY ("message_id") REFERENCES "public"."chat_message"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
80
+ CREATE INDEX "account_userId_idx" ON "account" USING btree ("user_id");--> statement-breakpoint
81
+ CREATE INDEX "chat_message_conversationId_idx" ON "chat_message" USING btree ("conversation_id");--> statement-breakpoint
82
+ CREATE INDEX "conversation_userId_idx" ON "conversation" USING btree ("user_id");--> statement-breakpoint
83
+ CREATE INDEX "session_userId_idx" ON "session" USING btree ("user_id");--> statement-breakpoint
84
+ CREATE INDEX "tool_call_messageId_idx" ON "tool_call" USING btree ("message_id");--> statement-breakpoint
85
+ CREATE INDEX "verification_identifier_idx" ON "verification" USING btree ("identifier");