mirror of
https://github.com/langchain-ai/oap-agent-supervisor.git
synced 2026-07-01 20:04:03 -04:00
refactor: Reorg project
This commit is contained in:
+161
-1
@@ -1,2 +1,162 @@
|
||||
.langgraph_api/
|
||||
.vs/
|
||||
.vscode/
|
||||
.idea/
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Swp files
|
||||
*.swp
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
pip-wheel-metadata/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# Google GitHub Actions credentials files created by:
|
||||
# https://github.com/google-github-actions/auth
|
||||
#
|
||||
# That action recommends adding this gitignore to prevent accidentally committing keys.
|
||||
gha-creds-*.json
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
.codspeed/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
docs/docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
notebooks/
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
.envrc
|
||||
.venv*
|
||||
venv*
|
||||
env/
|
||||
ENV/
|
||||
env.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.mypy_cache_test/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# macOS display setting files
|
||||
.DS_Store
|
||||
|
||||
# Wandb directory
|
||||
wandb/
|
||||
|
||||
# asdf tool versions
|
||||
.tool-versions
|
||||
/.ruff_cache/
|
||||
|
||||
node_modules
|
||||
_dist
|
||||
|
||||
prof
|
||||
virtualenv/
|
||||
|
||||
+2
-2
@@ -3,10 +3,10 @@
|
||||
"."
|
||||
],
|
||||
"graphs": {
|
||||
"agent": "./agent.py:graph"
|
||||
"agent": "./oap_supervisor/agent.py:graph"
|
||||
},
|
||||
"env": ".env",
|
||||
"auth": {
|
||||
"path": "./auth.py:auth"
|
||||
"path": "./oap_supervisor/security/auth.py:auth"
|
||||
}
|
||||
}
|
||||
@@ -46,9 +46,16 @@ class GraphConfigPydantic(BaseModel):
|
||||
)
|
||||
|
||||
|
||||
def make_child_graphs(cfg: GraphConfigPydantic, access_token: str):
|
||||
def make_child_graphs(cfg: GraphConfigPydantic, access_token: Optional[str] = None):
|
||||
"""
|
||||
Instantiate a list of RemoteGraph nodes based on the configuration.
|
||||
|
||||
Args:
|
||||
cfg: The configuration for the graph
|
||||
access_token: The Supabase access token for authentication, can be None
|
||||
|
||||
Returns:
|
||||
A list of RemoteGraph instances
|
||||
"""
|
||||
import re
|
||||
|
||||
@@ -58,19 +65,25 @@ def make_child_graphs(cfg: GraphConfigPydantic, access_token: str):
|
||||
# Remove any other disallowed characters (<, >, |, \, /)
|
||||
sanitized = re.sub(r"[<|\\/>]", "", sanitized)
|
||||
return sanitized
|
||||
|
||||
|
||||
# If no agents in config, return empty list
|
||||
if not cfg.agents:
|
||||
return []
|
||||
|
||||
# If access_token is None, create headers without token
|
||||
headers = {}
|
||||
if access_token:
|
||||
headers = {
|
||||
"Authorization": f"Bearer {access_token}",
|
||||
"x-supabase-access-token": access_token,
|
||||
}
|
||||
|
||||
return [
|
||||
RemoteGraph(
|
||||
a.agent_id,
|
||||
url=a.deployment_url,
|
||||
name=sanitize_name(a.name),
|
||||
headers={
|
||||
# The Authorization header is required to authenticate the request,
|
||||
# and the x-supabase-access-token header is required to authenticate
|
||||
# the tools
|
||||
"Authorization": f"Bearer {access_token}",
|
||||
"x-supabase-access-token": access_token,
|
||||
},
|
||||
headers=headers,
|
||||
)
|
||||
for a in cfg.agents
|
||||
]
|
||||
@@ -88,8 +101,9 @@ def make_prompt(cfg: GraphConfigPydantic):
|
||||
|
||||
def graph(config: RunnableConfig):
|
||||
cfg = GraphConfigPydantic(**config.get("configurable", {}))
|
||||
supabase_access_token = config.get("x-supabase-access-token")
|
||||
|
||||
supabase_access_token = config.get("configurable", {}).get("x-supabase-access-token")
|
||||
|
||||
# Pass the token to make_child_graphs, which now handles None values
|
||||
child_graphs = make_child_graphs(cfg, supabase_access_token)
|
||||
|
||||
return create_supervisor(
|
||||
@@ -0,0 +1,29 @@
|
||||
[project]
|
||||
name = "oap-supervisor"
|
||||
version = "0.1.0"
|
||||
description = "LangGraph supervisor agent for Open Agent Platform"
|
||||
authors = [
|
||||
{ name = "langchain-ai" },
|
||||
]
|
||||
requires-python = ">=3.11.0,<3.13"
|
||||
dependencies = [
|
||||
"langgraph==0.4.3",
|
||||
"langchain-core==0.3.59",
|
||||
"langchain-openai==0.3.16",
|
||||
"pydantic==2.11.3",
|
||||
"supabase>=2.15.1",
|
||||
"aiohttp>=3.8.0",
|
||||
"langgraph-supervisor>=0.0.21",
|
||||
]
|
||||
|
||||
[tool.setuptools]
|
||||
packages = ["oap_supervisor"]
|
||||
|
||||
[dependency-groups]
|
||||
dev = [
|
||||
"ruff>=0.8.4",
|
||||
"langgraph-api==0.2.21",
|
||||
"langgraph-cli==0.2.10",
|
||||
"langgraph-runtime-inmem>=0.0.11",
|
||||
"python-dotenv>=1.1.0",
|
||||
]
|
||||
@@ -1,13 +0,0 @@
|
||||
python-dotenv
|
||||
typing-extensions
|
||||
langgraph>=0.4.3
|
||||
langchain-core
|
||||
langchain-openai
|
||||
langchain-anthropic
|
||||
langgraph-supervisor>=0.0.21
|
||||
langchain-community
|
||||
scikit-learn
|
||||
openai
|
||||
ipython
|
||||
supabase
|
||||
ruff
|
||||
Reference in New Issue
Block a user