Skip to content

Commit

Permalink
fix cli import issue when magentic is not installed (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
wenzhe-log10 authored Apr 12, 2024
1 parent f1245b1 commit e6933b4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion log10/feedback/autofeedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@
from rich.console import Console

from log10.completions.completions import _get_completion
from log10.feedback._summary_feedback_utils import flatten_messages, summary_feedback_llm_call
from log10.feedback.feedback import _get_feedback_list
from log10.load import log10, log10_session


try:
from log10.feedback._summary_feedback_utils import flatten_messages, summary_feedback_llm_call

Magentic_imported = True
except ImportError:
Magentic_imported = False

log10(openai)

logger = logging.getLogger("LOG10")
Expand All @@ -28,6 +34,10 @@ class AutoFeedbackICL:
_predict_func: FunctionType = None

def __init__(self, task_id: str, num_samples: int = 5, predict_func: FunctionType = summary_feedback_llm_call):
if not Magentic_imported:
raise ImportError(
"Log10 feedback predict requires magentic package. Please install using 'pip install log10-io[autofeedback_icl]'"
)
self.num_samples = num_samples
self.task_id = task_id
self._predict_func = predict_func
Expand Down

0 comments on commit e6933b4

Please sign in to comment.