Spaces:
Runtime error
Runtime error
Commit
·
7f7cb09
1
Parent(s):
f4f38ff
Made changes for making protect work with different projects
Browse files- backend/api/main.py +1 -1
- backend/classes/galileo_platform.py +9 -12
- backend/conf/config.yaml +1 -0
backend/api/main.py
CHANGED
|
@@ -82,7 +82,7 @@ default_dataset_name = env_variables["GALILEO_DATASET_NAME"]
|
|
| 82 |
|
| 83 |
# Create Galileo platform object
|
| 84 |
galileo_platform_config = GalileoPlatformConfig(
|
| 85 |
-
protect_project_name=env_variables["
|
| 86 |
protect_stage_name=env_variables["GALILEO_PROTECT_STAGE_NAME"],
|
| 87 |
)
|
| 88 |
galileo_platform = GalileoPlatform(galileo_platform_config)
|
|
|
|
| 82 |
|
| 83 |
# Create Galileo platform object
|
| 84 |
galileo_platform_config = GalileoPlatformConfig(
|
| 85 |
+
protect_project_name=env_variables["GALILEO_PROTECT_PROJECT_NAME"],
|
| 86 |
protect_stage_name=env_variables["GALILEO_PROTECT_STAGE_NAME"],
|
| 87 |
)
|
| 88 |
galileo_platform = GalileoPlatform(galileo_platform_config)
|
backend/classes/galileo_platform.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
-
from pydantic import BaseModel
|
| 2 |
from dotenv import load_dotenv
|
| 3 |
from typing import Any
|
| 4 |
-
from pydantic import UUID4
|
| 5 |
|
| 6 |
from galileo import GalileoLogger, GalileoScorers, StageType
|
| 7 |
from galileo.log_streams import create_log_stream, get_log_stream
|
|
@@ -48,20 +47,18 @@ class GalileoPlatform:
|
|
| 48 |
|
| 49 |
def get_protect_stage_id(self) -> str | UUID4 | None:
|
| 50 |
"""Get or create a Galileo Protect stage."""
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
except Exception as _:
|
| 58 |
protect_stage = create_protect_stage(
|
| 59 |
project_name=self.config.protect_project_name,
|
| 60 |
name=self.config.protect_stage_name,
|
| 61 |
-
stage_type=StageType.local
|
| 62 |
-
description="Deutsche Bank RFP RAG Protect Stage"
|
| 63 |
)
|
| 64 |
-
|
| 65 |
|
| 66 |
def run_protect(self, input: str, output: str, logger: GalileoLogger | None = None) -> dict[Any, Any]:
|
| 67 |
"""Run Galileo Protect on input and output."""
|
|
|
|
| 1 |
+
from pydantic import BaseModel, UUID4
|
| 2 |
from dotenv import load_dotenv
|
| 3 |
from typing import Any
|
|
|
|
| 4 |
|
| 5 |
from galileo import GalileoLogger, GalileoScorers, StageType
|
| 6 |
from galileo.log_streams import create_log_stream, get_log_stream
|
|
|
|
| 47 |
|
| 48 |
def get_protect_stage_id(self) -> str | UUID4 | None:
|
| 49 |
"""Get or create a Galileo Protect stage."""
|
| 50 |
+
|
| 51 |
+
protect_stage = get_protect_stage(
|
| 52 |
+
project_name=self.config.protect_project_name,
|
| 53 |
+
stage_name=self.config.protect_stage_name,
|
| 54 |
+
)
|
| 55 |
+
if not protect_stage:
|
|
|
|
| 56 |
protect_stage = create_protect_stage(
|
| 57 |
project_name=self.config.protect_project_name,
|
| 58 |
name=self.config.protect_stage_name,
|
| 59 |
+
stage_type=StageType.local
|
|
|
|
| 60 |
)
|
| 61 |
+
return protect_stage.id
|
| 62 |
|
| 63 |
def run_protect(self, input: str, output: str, logger: GalileoLogger | None = None) -> dict[Any, Any]:
|
| 64 |
"""Run Galileo Protect on input and output."""
|
backend/conf/config.yaml
CHANGED
|
@@ -8,6 +8,7 @@ env_variables:
|
|
| 8 |
- GALILEO_DATASET_NAME
|
| 9 |
- GALILEO_LOGSTREAM_NAME
|
| 10 |
- GALILEO_PROJECT_NAME
|
|
|
|
| 11 |
- GALILEO_PROTECT_STAGE_NAME
|
| 12 |
- OPENAI_MODEL
|
| 13 |
- OPENAI_API_KEY
|
|
|
|
| 8 |
- GALILEO_DATASET_NAME
|
| 9 |
- GALILEO_LOGSTREAM_NAME
|
| 10 |
- GALILEO_PROJECT_NAME
|
| 11 |
+
- GALILEO_PROTECT_PROJECT_NAME
|
| 12 |
- GALILEO_PROTECT_STAGE_NAME
|
| 13 |
- OPENAI_MODEL
|
| 14 |
- OPENAI_API_KEY
|