Spaces:
Build error
Build error
Update utils.py
Browse files1234567891031 unmodified lines42434445464748495051525354from huggingface_hub import InferenceClientfrom dotenv import load_dotenvimport osimport pandas as pdload_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 -----------------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 textanswer = response[0]["generated_text"] if isinstance(response, list) and "generated_text" in response[0] else str(response)# ----------------- Option 2 ends here -----------------return answer123456731 unmodified lines3940414243444546474849505152535455from huggingface_hub import InferenceClientimport osimport pandas as pddef 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):"""# Initialize the InferenceClientclient = InferenceClient(token=os.environ.get("HUGGINGFACE_API_KEY"))# Use the text_generation method with the correct parametersresponse = client.text_generation(model="google/gemma-2b-it",inputs=prompt,parameters={"max_new_tokens": 1024, "temperature": 0.7})# Extract the generated text from the responseanswer = response[0]["generated_text"] if isinstance(response, list) and "generated_text" in response[0] else str(response)return answer
utils.py+9-8