88
99from typing import Optional , List
1010import tkinter as tk
11+ from tkinter import messagebox
1112from pydantic import BaseModel , ValidationError , Field , ConfigDict
12- from openai import OpenAI
1313from file_handling .data_import import import_data
1414from file_handling .data_conversion import make_str_enum , save_as_csv , to_long_df
15- from settings import secrets_store , config
15+ from settings import config
16+ from batch_processing .batch_method import get_client
1617
1718# Progress UI lives in a separate module
1819from ui .progress_ui import ProgressController
1920
20- # Initialize OpenAI client with stored API key
21- try :
22- OPENAI_API_KEY = secrets_store .load_api_key ()
23- client = OpenAI (api_key = OPENAI_API_KEY ) if OPENAI_API_KEY else None
24- except Exception :
25- OPENAI_API_KEY = None
26- client = None
27-
2821
2922def multi_label_pipeline (parent : Optional [tk .Misc ] = None ):
3023 """
3124 Prompt for labels/quotes CSVs, classify each quote with 1+ labels,
3225 show progress, then save results to CSV.
3326 """
27+ try :
28+ client = get_client ()
29+ except Exception as e :
30+ messagebox .showerror ("API Key Required" , str (e ))
31+ return
32+
3433 # Get labels data
3534 from_import = import_data (parent , "Select the labels data" )
3635 if from_import is None :
@@ -47,7 +46,7 @@ def multi_label_pipeline(parent: Optional[tk.Misc] = None):
4746 class LabeledQuoteMulti (BaseModel ):
4847 id : int | None = None
4948 quote : str
50- label : List [labels ] = Field (..., min_items = 1 )
49+ label : List [labels ] = Field (..., min_length = 1 )
5150 model_config = ConfigDict (use_enum_values = True , extra = 'forbid' )
5251
5352 total = len (quotes )
0 commit comments