Spaces:
Build error
Build error
Update utils.py
Browse files122346756731 unmodified lines39404145424347484450454647484950515253525455from huggingface_hub import InferenceClientfrom dotenv import load_dotenvimport osimport pandas as pd
load_dotenv()
def summarize_dataframe(df: pd.DataFrame, max_rows: int = 30) -> str: summary = f"Columns: {', '.join(df.columns)}\n\n" if len(df) > max_rows:31 unmodified linesAnswer (with explanation):"""
# ----------------- Option 2 starts here ----------------- # Initialize the InferenceClient client = InferenceClient(token=os.environ.get("HUGGINGFACE_API_KEY")) # Use a model that supports text-generation (TGI-compatible) response = client.text_generation(prompt, model="mistralai/Mistral-7B-Instruct-v0.3")
# Extract the text # Use the text_generation method with the correct parameters response = client.text_generation( model="google/gemma-2b-it", inputs=prompt, parameters={"max_new_tokens": 1024, "temperature": 0.7} )
# Extract the generated text from the response answer = response[0]["generated_text"] if isinstance(response, list) and "generated_text" in response[0] else str(response) # ----------------- Option 2 ends here -----------------
return answerutils.py+9-8