Spaces:
Running
Running
Sync from GitHub via hub-sync
Browse files
config.py
CHANGED
|
@@ -96,61 +96,6 @@ class Settings(BaseSettings):
|
|
| 96 |
return key
|
| 97 |
|
| 98 |
|
| 99 |
-
# βββ Observability CLI βββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
@config.command(name="set-observability")
|
| 103 |
-
@click.option("--langsmith-api-key", help="LangSmith API key (for tracing)")
|
| 104 |
-
@click.option("--langsmith-project", default="opencodereview", show_default=True,
|
| 105 |
-
help="LangSmith project name")
|
| 106 |
-
@click.option("--langfuse-public-key", help="Langfuse public key")
|
| 107 |
-
@click.option("--langfuse-secret-key", help="Langfuse secret key")
|
| 108 |
-
@click.option("--langfuse-host", default="https://cloud.langfuse.com",
|
| 109 |
-
show_default=True, help="Langfuse host URL")
|
| 110 |
-
def set_observability(
|
| 111 |
-
langsmith_api_key: Optional[str],
|
| 112 |
-
langsmith_project: str,
|
| 113 |
-
langfuse_public_key: Optional[str],
|
| 114 |
-
langfuse_secret_key: Optional[str],
|
| 115 |
-
langfuse_host: str,
|
| 116 |
-
) -> None:
|
| 117 |
-
"""Configure observability backends (LangSmith and/or Langfuse).
|
| 118 |
-
|
| 119 |
-
Keys are stored in the system keyring. Both backends can be configured
|
| 120 |
-
simultaneously with no conflict. If neither is set, the app runs
|
| 121 |
-
exactly as before with zero tracing overhead.
|
| 122 |
-
"""
|
| 123 |
-
if langsmith_api_key:
|
| 124 |
-
keyring.set_password(SERVICE_NAME, "langsmith_api_key", langsmith_api_key)
|
| 125 |
-
click.echo(f"LangSmith API key saved (project: {langsmith_project}).")
|
| 126 |
-
|
| 127 |
-
# Warn if env var is already set
|
| 128 |
-
if os.environ.get("LANGCHAIN_API_KEY"):
|
| 129 |
-
click.echo(
|
| 130 |
-
" Note: LANGCHAIN_API_KEY env var is already set β "
|
| 131 |
-
"it takes precedence over the keyring value.",
|
| 132 |
-
err=True,
|
| 133 |
-
)
|
| 134 |
-
else:
|
| 135 |
-
click.echo(" LangSmith: skipped (no --langsmith-api-key provided).")
|
| 136 |
-
|
| 137 |
-
if langfuse_public_key and langfuse_secret_key:
|
| 138 |
-
keyring.set_password(SERVICE_NAME, "langfuse_public_key", langfuse_public_key)
|
| 139 |
-
keyring.set_password(SERVICE_NAME, "langfuse_secret_key", langfuse_secret_key)
|
| 140 |
-
keyring.set_password(SERVICE_NAME, "langfuse_host", langfuse_host)
|
| 141 |
-
click.echo(f"Langfuse keys saved (host: {langfuse_host}).")
|
| 142 |
-
|
| 143 |
-
if os.environ.get("LANGFUSE_PUBLIC_KEY"):
|
| 144 |
-
click.echo(
|
| 145 |
-
" Note: LANGFUSE_PUBLIC_KEY env var is already set β "
|
| 146 |
-
"it takes precedence.",
|
| 147 |
-
err=True,
|
| 148 |
-
)
|
| 149 |
-
else:
|
| 150 |
-
click.echo(" Langfuse: skipped (need both --langfuse-public-key "
|
| 151 |
-
"and --langfuse-secret-key).")
|
| 152 |
-
|
| 153 |
-
|
| 154 |
# βββ Key masking βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 155 |
|
| 156 |
|
|
@@ -264,3 +209,59 @@ def show() -> None:
|
|
| 264 |
click.echo(" No keys or tokens configured.")
|
| 265 |
click.echo(" Run: opencodereview config set-key --provider anthropic")
|
| 266 |
click.echo()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
return key
|
| 97 |
|
| 98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
# βββ Key masking βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 100 |
|
| 101 |
|
|
|
|
| 209 |
click.echo(" No keys or tokens configured.")
|
| 210 |
click.echo(" Run: opencodereview config set-key --provider anthropic")
|
| 211 |
click.echo()
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
# βββ Observability CLI βββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
@config.command(name="set-observability")
|
| 218 |
+
@click.option("--langsmith-api-key", help="LangSmith API key (for tracing)")
|
| 219 |
+
@click.option("--langsmith-project", default="opencodereview", show_default=True,
|
| 220 |
+
help="LangSmith project name")
|
| 221 |
+
@click.option("--langfuse-public-key", help="Langfuse public key")
|
| 222 |
+
@click.option("--langfuse-secret-key", help="Langfuse secret key")
|
| 223 |
+
@click.option("--langfuse-host", default="https://cloud.langfuse.com",
|
| 224 |
+
show_default=True, help="Langfuse host URL")
|
| 225 |
+
def set_observability(
|
| 226 |
+
langsmith_api_key: Optional[str],
|
| 227 |
+
langsmith_project: str,
|
| 228 |
+
langfuse_public_key: Optional[str],
|
| 229 |
+
langfuse_secret_key: Optional[str],
|
| 230 |
+
langfuse_host: str,
|
| 231 |
+
) -> None:
|
| 232 |
+
"""Configure observability backends (LangSmith and/or Langfuse).
|
| 233 |
+
|
| 234 |
+
Keys are stored in the system keyring. Both backends can be configured
|
| 235 |
+
simultaneously with no conflict. If neither is set, the app runs
|
| 236 |
+
exactly as before with zero tracing overhead.
|
| 237 |
+
"""
|
| 238 |
+
if langsmith_api_key:
|
| 239 |
+
keyring.set_password(SERVICE_NAME, "langsmith_api_key", langsmith_api_key)
|
| 240 |
+
click.echo(f"LangSmith API key saved (project: {langsmith_project}).")
|
| 241 |
+
|
| 242 |
+
# Warn if env var is already set
|
| 243 |
+
if os.environ.get("LANGCHAIN_API_KEY"):
|
| 244 |
+
click.echo(
|
| 245 |
+
" Note: LANGCHAIN_API_KEY env var is already set β "
|
| 246 |
+
"it takes precedence over the keyring value.",
|
| 247 |
+
err=True,
|
| 248 |
+
)
|
| 249 |
+
else:
|
| 250 |
+
click.echo(" LangSmith: skipped (no --langsmith-api-key provided).")
|
| 251 |
+
|
| 252 |
+
if langfuse_public_key and langfuse_secret_key:
|
| 253 |
+
keyring.set_password(SERVICE_NAME, "langfuse_public_key", langfuse_public_key)
|
| 254 |
+
keyring.set_password(SERVICE_NAME, "langfuse_secret_key", langfuse_secret_key)
|
| 255 |
+
keyring.set_password(SERVICE_NAME, "langfuse_host", langfuse_host)
|
| 256 |
+
click.echo(f"Langfuse keys saved (host: {langfuse_host}).")
|
| 257 |
+
|
| 258 |
+
if os.environ.get("LANGFUSE_PUBLIC_KEY"):
|
| 259 |
+
click.echo(
|
| 260 |
+
" Note: LANGFUSE_PUBLIC_KEY env var is already set β "
|
| 261 |
+
"it takes precedence.",
|
| 262 |
+
err=True,
|
| 263 |
+
)
|
| 264 |
+
else:
|
| 265 |
+
click.echo(" Langfuse: skipped (need both --langfuse-public-key "
|
| 266 |
+
"and --langfuse-secret-key).")
|
| 267 |
+
|