Spaces:
Sleeping
Sleeping
Ronio Jerico Roque commited on
Commit ·
33dc83e
1
Parent(s): 83a4aff
Refactor database connection to use environment variable and update MCP server URL
Browse files- .env +2 -1
- .gitignore +114 -0
- __pycache__/app.cpython-313.pyc +0 -0
- agent.py +1 -1
- app.py +2 -2
.env
CHANGED
|
@@ -1 +1,2 @@
|
|
| 1 |
-
OPENAI_API_KEY=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
|
|
|
|
|
|
| 1 |
+
OPENAI_API_KEY=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
|
| 2 |
+
db=postgres://postgres:apple@172.17.21.23:5432/agency_data
|
.gitignore
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Environment variables
|
| 2 |
+
.env
|
| 3 |
+
.env.local
|
| 4 |
+
.env.development
|
| 5 |
+
.env.test
|
| 6 |
+
.env.production
|
| 7 |
+
|
| 8 |
+
# Python
|
| 9 |
+
__pycache__/
|
| 10 |
+
*.py[cod]
|
| 11 |
+
*$py.class
|
| 12 |
+
*.so
|
| 13 |
+
.Python
|
| 14 |
+
build/
|
| 15 |
+
develop-eggs/
|
| 16 |
+
dist/
|
| 17 |
+
downloads/
|
| 18 |
+
eggs/
|
| 19 |
+
.eggs/
|
| 20 |
+
lib/
|
| 21 |
+
lib64/
|
| 22 |
+
parts/
|
| 23 |
+
sdist/
|
| 24 |
+
var/
|
| 25 |
+
wheels/
|
| 26 |
+
share/python-wheels/
|
| 27 |
+
*.egg-info/
|
| 28 |
+
.installed.cfg
|
| 29 |
+
*.egg
|
| 30 |
+
MANIFEST
|
| 31 |
+
|
| 32 |
+
# Virtual environments
|
| 33 |
+
.venv/
|
| 34 |
+
venv/
|
| 35 |
+
ENV/
|
| 36 |
+
env/
|
| 37 |
+
.env/
|
| 38 |
+
|
| 39 |
+
# IDE
|
| 40 |
+
.vscode/
|
| 41 |
+
.idea/
|
| 42 |
+
*.swp
|
| 43 |
+
*.swo
|
| 44 |
+
*~
|
| 45 |
+
|
| 46 |
+
# OS
|
| 47 |
+
.DS_Store
|
| 48 |
+
.DS_Store?
|
| 49 |
+
._*
|
| 50 |
+
.Spotlight-V100
|
| 51 |
+
.Trashes
|
| 52 |
+
ehthumbs.db
|
| 53 |
+
Thumbs.db
|
| 54 |
+
|
| 55 |
+
# Logs
|
| 56 |
+
*.log
|
| 57 |
+
logs/
|
| 58 |
+
log/
|
| 59 |
+
|
| 60 |
+
# Database
|
| 61 |
+
*.db
|
| 62 |
+
*.sqlite
|
| 63 |
+
*.sqlite3
|
| 64 |
+
|
| 65 |
+
# Cache
|
| 66 |
+
.cache/
|
| 67 |
+
.pytest_cache/
|
| 68 |
+
.coverage
|
| 69 |
+
htmlcov/
|
| 70 |
+
|
| 71 |
+
# Jupyter Notebook
|
| 72 |
+
.ipynb_checkpoints
|
| 73 |
+
|
| 74 |
+
# FastAPI
|
| 75 |
+
.pytest_cache/
|
| 76 |
+
|
| 77 |
+
# Node modules (if any frontend)
|
| 78 |
+
node_modules/
|
| 79 |
+
|
| 80 |
+
# Temporary files
|
| 81 |
+
*.tmp
|
| 82 |
+
*.temp
|
| 83 |
+
temp/
|
| 84 |
+
tmp/
|
| 85 |
+
|
| 86 |
+
# API Keys and secrets
|
| 87 |
+
secrets.json
|
| 88 |
+
config.json
|
| 89 |
+
credentials.json
|
| 90 |
+
|
| 91 |
+
# Test files
|
| 92 |
+
test_*.py
|
| 93 |
+
*_test.py
|
| 94 |
+
tests/
|
| 95 |
+
|
| 96 |
+
# Documentation builds
|
| 97 |
+
docs/_build/
|
| 98 |
+
|
| 99 |
+
# Coverage reports
|
| 100 |
+
.coverage
|
| 101 |
+
coverage.xml
|
| 102 |
+
*.cover
|
| 103 |
+
.hypothesis/
|
| 104 |
+
|
| 105 |
+
# mypy
|
| 106 |
+
.mypy_cache/
|
| 107 |
+
.dmypy.json
|
| 108 |
+
dmypy.json
|
| 109 |
+
|
| 110 |
+
# Pyre type checker
|
| 111 |
+
.pyre/
|
| 112 |
+
|
| 113 |
+
# Local development
|
| 114 |
+
local_settings.py
|
__pycache__/app.cpython-313.pyc
CHANGED
|
Binary files a/__pycache__/app.cpython-313.pyc and b/__pycache__/app.cpython-313.pyc differ
|
|
|
agent.py
CHANGED
|
@@ -19,7 +19,7 @@ llm_with_tools = llm.bind_tools(
|
|
| 19 |
{
|
| 20 |
"type": "mcp",
|
| 21 |
"server_label": "clickup_data",
|
| 22 |
-
"server_url": "
|
| 23 |
"require_approval": "never",
|
| 24 |
}
|
| 25 |
]
|
|
|
|
| 19 |
{
|
| 20 |
"type": "mcp",
|
| 21 |
"server_label": "clickup_data",
|
| 22 |
+
"server_url": "https://roniorque-fastapi-test-server.hf.space/mcp",
|
| 23 |
"require_approval": "never",
|
| 24 |
}
|
| 25 |
]
|
app.py
CHANGED
|
@@ -41,8 +41,8 @@ async def query_postgres(input_data: QueryInput) -> ToolOutput:
|
|
| 41 |
# Only allow SELECT queries
|
| 42 |
if not input_data.query.lower().strip().startswith('select'):
|
| 43 |
return ToolOutput(result="Error: Only SELECT queries are allowed")
|
| 44 |
-
|
| 45 |
-
conn = await asyncpg.connect(
|
| 46 |
rows = await conn.fetch(input_data.query + " LIMIT 10")
|
| 47 |
await conn.close()
|
| 48 |
|
|
|
|
| 41 |
# Only allow SELECT queries
|
| 42 |
if not input_data.query.lower().strip().startswith('select'):
|
| 43 |
return ToolOutput(result="Error: Only SELECT queries are allowed")
|
| 44 |
+
|
| 45 |
+
conn = await asyncpg.connect(dsn=os.getenv("db"))
|
| 46 |
rows = await conn.fetch(input_data.query + " LIMIT 10")
|
| 47 |
await conn.close()
|
| 48 |
|