-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
61 lines (51 loc) · 1.71 KB
/
app.py
File metadata and controls
61 lines (51 loc) · 1.71 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
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from api.routes import comments
from models.schema import CommandRequest
from enclov_commands import allowed_funcs
from app.routes import submit_pr # adjust path as needed
from fastapi import FastAPI
from submit_pr import router as submit_pr_router
from providers.enclovai_provider import call_enclovai
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # or specific origin
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
def process_prompt(prompt, model="auto"):
return call_enclovai(prompt, model=model)
if __name__ == "__main__":
prompt = input("Enter your prompt: ")
provider = input("Choose provider (openai/google/auto): ").strip().lower()
response = process_prompt(prompt, model=provider)
print("\n=== Response ===\n")
print(response)
app = FastAPI(
title="Enclov-AI",
version="0.1.0",
description="Privacy-first AI assistant for CLI + PR automation"
)
app = FastAPI()
app.include_router(submit_pr_router)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Caution: lock this down in prod
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(submit_pr.router)
# CLI command endpoint
@app.post("/api/run")
async def run_command(req: CommandRequest):
cmd = req.command.strip()
func = allowed_funcs.get(cmd)
if not func:
return {"output": f"❌ Unknown command: '{cmd}'\nType 'enclov help' for help."}
try:
return {"output": func()}
except Exception as e:
return {"output": f"🔥 Error while executing '{cmd}': {str(e)}"}
# GitHub Webhook endpoint
app.include_router(comments.router)