Skip to content

Commit

Permalink
Merge pull request #50 from Snowflake-Labs/release-11082024
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
sfc-gh-bklein authored Nov 8, 2024
2 parents 3c60124 + cd1d7a8 commit 59cc0e6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions framework-evalanche/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ To remove a metric as selectable in the app, deselect it in the Manage Metrics m
CALL GENAI_UTILITIES.EVALUATION.DELETE_METRIC('Rudeness');
```

Lastly, please be aware that Streamlit in Snowflake now supports multiple python versions. Custom metrics may only be available with consistent Python versions. For example, if you create a custom metric while running the app with Python version 3.11, the custom metric will only be available in subsequent sessions when running Python 3.11.

## Crafting a LLM Pipeline Stored Procedure
To run a reference dataset through your desired LLM pipelines on the data page, we must first encapsulated the pipeline logic in a Stored Procedure. To take advantage of this feature, the stored procedure must have a single VARIANT input type and return a single value. When we execute the stored procedure, a single row from the reference dataset will be passed in the form of a Python dictionary. In other words, a row in the reference dataset that looks like:
```markdown
Expand Down
2 changes: 1 addition & 1 deletion framework-evalanche/pages/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ def show_recommendation(selection: Union[int, None], pandas_df: pd.DataFrame) ->
(
metric
for metric in metrics
if metric.name.upper() == selected_metric_name.upper()
if metric.get_column() == selected_metric_name.upper()
),
None,
)
Expand Down
Binary file modified framework-evalanche/src.zip
Binary file not shown.
11 changes: 8 additions & 3 deletions framework-evalanche/src/app_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ def load_staged_pickle(session: Session, staged_file_path: str) -> Any:
# Load the pickled instance from the file
local_file = '/tmp/' + staged_file_path.split("/")[-1]
with open(local_file, "rb") as f:
loaded_instance = pickle.load(f)
return loaded_instance
loaded_instance = pickle.load(f)
return loaded_instance


def delete_metric(session: Session, metric: Metric, stage_name: str):
"""Deletes metric pickle file from Snowflake stage."""
Expand Down Expand Up @@ -157,7 +158,11 @@ def fetch_custom_metrics_from_stage(session: Session,
for f in files:
stage_file_path = f"@{stage_name}/{f.split('/')[-1]}" # Non-qualified stage name in LS from @stage results
if stage_file_path in metrics_to_show:
custom_metrics.append(load_staged_pickle(session, stage_file_path))
try:
custom_metrics.append(load_staged_pickle(session, stage_file_path))
except TypeError:
st.warning(f"Error loading metric {stage_file_path}. This can occur if the metric was created with a different python version than what is being used.")
continue
return custom_metrics
else:
return []
Expand Down
2 changes: 1 addition & 1 deletion framework-evalanche/src/snowflake_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,5 +277,5 @@ def call_sproc(session: Session, name: str) -> Any:
return session.call(name)


def call_async_sproc(session: Session, sproc: str, input_value: dict[str, Any]) -> Any:
def call_async_sproc(session: Session, sproc: str, input_value: Dict[str, Any]) -> Any:
return session.sql(f"CALL {sproc}({input_value})").collect_nowait().result()[0][0]

0 comments on commit 59cc0e6

Please sign in to comment.