Skip to content

Commit

Permalink
fix checkset run for managed user (#572)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashish-1600 authored Mar 1, 2024
1 parent ad9dc4d commit 9ba6489
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 40 deletions.
4 changes: 2 additions & 2 deletions uptrain/operators/code/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def setup(self, settings: t.Optional[Settings] = None):

assert settings is not None
self.settings = settings
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
self._api_client = LLMMulticlient(settings)
else:
self._api_client = APIClient(settings)
Expand All @@ -70,7 +70,7 @@ def run(self, data: pl.DataFrame) -> TYPE_TABLE_OUTPUT:
row["context"] = row.pop(self.col_context)

try:
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
results = self.evaluate_local(data_send)
else:
results = self._api_client.evaluate("code_hallucination", data_send)
Expand Down
16 changes: 8 additions & 8 deletions uptrain/operators/language/context_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def setup(self, settings: t.Optional[Settings] = None):

assert settings is not None
self.settings = settings
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
self._api_client = LLMMulticlient(settings)
else:
self._api_client = APIClient(settings)
Expand All @@ -91,7 +91,7 @@ def run(self, data: pl.DataFrame) -> TYPE_TABLE_OUTPUT:
row["context"] = row.pop(self.col_context)

try:
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
results = self.evaluate_local(data_send)
else:
results = self._api_client.evaluate(
Expand Down Expand Up @@ -224,7 +224,7 @@ def setup(self, settings: t.Optional[Settings] = None):

assert settings is not None
self.settings = settings
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
self._api_client = LLMMulticlient(settings)
else:
self._api_client = APIClient(settings)
Expand All @@ -238,7 +238,7 @@ def run(self, data: pl.DataFrame) -> TYPE_TABLE_OUTPUT:
row["context"] = row.pop(self.col_context)

try:
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
results = self.evaluate_local(data_send)
else:
results = self._api_client.evaluate(
Expand Down Expand Up @@ -382,7 +382,7 @@ def setup(self, settings: t.Optional[Settings] = None):

assert settings is not None
self.settings = settings
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
self._api_client = LLMMulticlient(settings)
else:
self._api_client = APIClient(settings)
Expand All @@ -396,7 +396,7 @@ def run(self, data: pl.DataFrame) -> TYPE_TABLE_OUTPUT:
row["reranked_context"] = row.pop(self.col_reranked_context)

try:
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
results = self.evaluate_local(data_send)
else:
results = self._api_client.evaluate(
Expand Down Expand Up @@ -530,7 +530,7 @@ def setup(self, settings: t.Optional[Settings] = None):

assert settings is not None
self.settings = settings
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
self._api_client = LLMMulticlient(settings)
else:
self._api_client = APIClient(settings)
Expand All @@ -544,7 +544,7 @@ def run(self, data: pl.DataFrame) -> TYPE_TABLE_OUTPUT:
row["concise_context"] = row.pop(self.col_concise_context)

try:
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
results = self.evaluate_local(data_send)
else:
results = self._api_client.evaluate(
Expand Down
4 changes: 2 additions & 2 deletions uptrain/operators/language/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def setup(self, settings: t.Optional[Settings] = None):

assert settings is not None
self.settings = settings
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
self._api_client = LLMMulticlient(settings)
else:
self._api_client = APIClient(settings)
Expand All @@ -79,7 +79,7 @@ def run(self, data: pl.DataFrame) -> TYPE_TABLE_OUTPUT:
row["conversation"] = row[self.col_conversation]

try:
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
results = self.evaluate_local(data_send)
else:
results = self._api_client.evaluate(
Expand Down
4 changes: 2 additions & 2 deletions uptrain/operators/language/factual_accuracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def setup(self, settings: t.Optional[Settings] = None):

assert settings is not None
self.settings = settings
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
self._api_client = LLMMulticlient(settings)
else:
self._api_client = APIClient(settings)
Expand All @@ -84,7 +84,7 @@ def run(self, data: pl.DataFrame) -> TYPE_TABLE_OUTPUT:
row["context"] = row.pop(self.col_context)

try:
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
results = self.evaluate_local(data_send)
else:
results = self._api_client.evaluate(
Expand Down
4 changes: 2 additions & 2 deletions uptrain/operators/language/guideline.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def setup(self, settings: t.Optional[Settings] = None):

assert settings is not None
self.settings = settings
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
self._api_client = LLMMulticlient(settings)
else:
self._api_client = APIClient(settings)
Expand All @@ -81,7 +81,7 @@ def run(self, data: pl.DataFrame) -> TYPE_TABLE_OUTPUT:
row["response"] = row.pop(self.col_response)

try:
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
results = self.evaluate_local(data_send)
else:
results = self._api_client.evaluate(
Expand Down
8 changes: 4 additions & 4 deletions uptrain/operators/language/jailbreak.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def setup(self, settings: t.Optional[Settings] = None):

assert settings is not None
self.settings = settings
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
self._api_client = LLMMulticlient(settings)
else:
self._api_client = APIClient(settings)
Expand All @@ -78,7 +78,7 @@ def run(self, data: pl.DataFrame) -> TYPE_TABLE_OUTPUT:
row["question"] = row.pop(self.col_question)

try:
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
results = self.evaluate_local(data_send)
else:
results = self._api_client.evaluate(
Expand Down Expand Up @@ -214,7 +214,7 @@ def setup(self, settings: t.Optional[Settings] = None):

assert settings is not None
self.settings = settings
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
self._api_client = LLMMulticlient(settings)
else:
self._api_client = APIClient(settings)
Expand All @@ -226,7 +226,7 @@ def run(self, data: pl.DataFrame) -> TYPE_TABLE_OUTPUT:
row["question"] = row.pop(self.col_question)

try:
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
results = self.evaluate_local(data_send)
else:
results = self._api_client.evaluate(
Expand Down
8 changes: 4 additions & 4 deletions uptrain/operators/language/language_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def setup(self, settings: t.Optional[Settings] = None):

assert settings is not None
self.settings = settings
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
self._api_client = LLMMulticlient(settings)
else:
self._api_client = APIClient(settings)
Expand All @@ -84,7 +84,7 @@ def run(self, data: pl.DataFrame) -> TYPE_TABLE_OUTPUT:
row["response"] = row.pop(self.col_response)

try:
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
results = self.evaluate_local(data_send)
else:
results = self._api_client.evaluate("critique_language", data_send)
Expand Down Expand Up @@ -212,7 +212,7 @@ def setup(self, settings: t.Optional[Settings] = None):

assert settings is not None
self.settings = settings
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
self._api_client = LLMMulticlient(settings)
else:
self._api_client = APIClient(settings)
Expand All @@ -224,7 +224,7 @@ def run(self, data: pl.DataFrame) -> TYPE_TABLE_OUTPUT:
row["response"] = row.pop(self.col_response)

try:
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
results = self.evaluate_local(data_send)
else:
results = self._api_client.evaluate("critique_language", data_send)
Expand Down
24 changes: 12 additions & 12 deletions uptrain/operators/language/response_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def setup(self, settings: t.Optional[Settings] = None):

assert settings is not None
self.settings = settings
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
self._api_client = LLMMulticlient(settings)
else:
self._api_client = APIClient(settings)
Expand All @@ -90,7 +90,7 @@ def run(self, data: pl.DataFrame) -> TYPE_TABLE_OUTPUT:
row["response"] = row.pop(self.col_response)

try:
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
results = self.evaluate_local(data_send)
else:
results = self._api_client.evaluate(
Expand Down Expand Up @@ -223,7 +223,7 @@ def setup(self, settings: t.Optional[Settings] = None):

assert settings is not None
self.settings = settings
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
self._api_client = LLMMulticlient(settings)
else:
self._api_client = APIClient(settings)
Expand All @@ -236,7 +236,7 @@ def run(self, data: pl.DataFrame) -> TYPE_TABLE_OUTPUT:
row["response"] = row.pop(self.col_response)

try:
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
results = self.evaluate_local(data_send)
else:
results = self._api_client.evaluate(
Expand Down Expand Up @@ -366,7 +366,7 @@ def setup(self, settings: t.Optional[Settings] = None):

assert settings is not None
self.settings = settings
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
self._api_client = LLMMulticlient(settings)
else:
self._api_client = APIClient(settings)
Expand All @@ -378,7 +378,7 @@ def run(self, data: pl.DataFrame) -> TYPE_TABLE_OUTPUT:
row["response"] = row.pop(self.col_response)

try:
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
results = self.evaluate_local(data_send)
else:
results = self._api_client.evaluate(
Expand Down Expand Up @@ -507,7 +507,7 @@ def setup(self, settings: t.Optional[Settings] = None):

assert settings is not None
self.settings = settings
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
self._api_client = LLMMulticlient(settings)
else:
self._api_client = APIClient(settings)
Expand All @@ -519,7 +519,7 @@ def run(self, data: pl.DataFrame) -> TYPE_TABLE_OUTPUT:
row["response"] = row.pop(self.col_response)

try:
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
results = self.evaluate_local(data_send)
else:
results = self._api_client.evaluate(
Expand Down Expand Up @@ -646,7 +646,7 @@ def setup(self, settings: t.Optional[Settings] = None):

assert settings is not None
self.settings = settings
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
self._api_client = LLMMulticlient(settings)
else:
self._api_client = APIClient(settings)
Expand All @@ -658,7 +658,7 @@ def run(self, data: pl.DataFrame) -> TYPE_TABLE_OUTPUT:
row["response"] = row.pop(self.col_response)

try:
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
results = self.evaluate_local(data_send)
else:
results = self._api_client.evaluate(
Expand Down Expand Up @@ -775,7 +775,7 @@ def setup(self, settings: t.Optional[Settings] = None):

assert settings is not None
self.settings = settings
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
# TODO: Add support for local evaluation for all methods
if self.method != "llm":
raise Exception(
Expand All @@ -796,7 +796,7 @@ def run(self, data: pl.DataFrame) -> TYPE_TABLE_OUTPUT:
row["ground_truth"] = row.pop(self.col_ground_truth)

try:
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
results = self.evaluate_local(data_send)
else:
results = self._api_client.evaluate(
Expand Down
4 changes: 2 additions & 2 deletions uptrain/operators/language/subquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def setup(self, settings: t.Optional[Settings] = None):

assert settings is not None
self.settings = settings
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
self._api_client = LLMMulticlient(settings)
else:
self._api_client = APIClient(settings)
Expand All @@ -72,7 +72,7 @@ def run(self, data: pl.DataFrame) -> TYPE_TABLE_OUTPUT:
row["sub_questions"] = row.pop(self.col_sub_questions)

try:
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
results = self.evaluate_local(data_send)
else:
results = self._api_client.evaluate(
Expand Down
4 changes: 2 additions & 2 deletions uptrain/operators/language/tone.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def setup(self, settings: t.Optional[Settings] = None):

assert settings is not None
self.settings = settings
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
self._api_client = LLMMulticlient(settings)
else:
self._api_client = APIClient(settings)
Expand All @@ -78,7 +78,7 @@ def run(self, data: pl.DataFrame) -> TYPE_TABLE_OUTPUT:
row["response"] = row.pop(self.col_response)

try:
if self.settings.evaluate_locally:
if self.settings.evaluate_locally and (self.settings.uptrain_access_token is None or not len(self.settings.uptrain_access_token)):
results = self.evaluate_local(data_send)
else:
results = self._api_client.evaluate(
Expand Down

0 comments on commit 9ba6489

Please sign in to comment.