Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use type rather than Type #119

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions langchain_benchmarks/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import dataclasses
import importlib
import urllib
import warnings
from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Type, Union

from langchain.prompts import ChatPromptTemplate
Expand Down Expand Up @@ -214,15 +215,26 @@ def _repr_html_(self) -> str:

def filter(
self,
Type: Optional[str],
*,
type: Optional[str] = None,
dataset_id: Optional[str] = None,
name: Optional[str] = None,
description: Optional[str] = None,
Type: Optional[str] = None, # For backwards compatibility:
) -> Registry:
"""Filter the tasks in the registry."""
tasks = self.tasks
if Type is not None:
tasks = [task for task in tasks if task.__class__.__name__ == Type]
if Type and type:
raise ValueError("Cannot filter by both Type and type.")

if Type is not None and type is None:
type_ = Type
warnings.warn("Type is deprecated, please use type instead.")
else:
type_ = type

if type_ is not None:
tasks = [task for task in tasks if task.__class__.__name__ == type]
if dataset_id is not None:
tasks = [task for task in tasks if task.dataset_id == dataset_id]
if name is not None:
Expand Down