Spaces:
Sleeping
Sleeping
Delete test.py
Browse files
test.py
DELETED
|
@@ -1,52 +0,0 @@
|
|
| 1 |
-
from lida import Manager, TextGenerationConfig , llm
|
| 2 |
-
from dotenv import load_dotenv
|
| 3 |
-
import os
|
| 4 |
-
import openai
|
| 5 |
-
import base64
|
| 6 |
-
from PIL import Image
|
| 7 |
-
from io import BytesIO
|
| 8 |
-
|
| 9 |
-
print("Import Successful!")
|
| 10 |
-
|
| 11 |
-
load_dotenv()
|
| 12 |
-
|
| 13 |
-
def base64_to_image(base64_string):
|
| 14 |
-
# Decode the base64 string
|
| 15 |
-
byte_data = base64.b64decode(base64_string)
|
| 16 |
-
|
| 17 |
-
# Use BytesIO to convert the byte data to image
|
| 18 |
-
return Image.open(BytesIO(byte_data))
|
| 19 |
-
|
| 20 |
-
def save_image(base64_str, save_path):
|
| 21 |
-
img = base64_to_image(base64_str)
|
| 22 |
-
img.save(save_path)
|
| 23 |
-
print(f"Image saved at {save_path}")
|
| 24 |
-
|
| 25 |
-
openai.api_key = os.getenv('OPENAI_API_KEY')
|
| 26 |
-
|
| 27 |
-
#text_gen = llm("openai")
|
| 28 |
-
#text_gen = llm(provider="hf", model="togethercomputer/Llama-2-7B-32K-Instruct", device_map="cpu")
|
| 29 |
-
|
| 30 |
-
lida = Manager(text_gen = llm("openai"))
|
| 31 |
-
|
| 32 |
-
print("Model Loaded Successfully!")
|
| 33 |
-
|
| 34 |
-
textgen_config = TextGenerationConfig(n=1, temperature=0.5, model="gpt-3.5-turbo-0301", use_cache=True)
|
| 35 |
-
|
| 36 |
-
summary = lida.summarize("2019.csv", summary_method="default", textgen_config=textgen_config)
|
| 37 |
-
|
| 38 |
-
print(summary)
|
| 39 |
-
|
| 40 |
-
goals = lida.goals(summary, n=2, textgen_config=textgen_config)
|
| 41 |
-
|
| 42 |
-
for goal in goals:
|
| 43 |
-
print(goal)
|
| 44 |
-
|
| 45 |
-
i = 0
|
| 46 |
-
library = "seaborn"
|
| 47 |
-
textgen_config = TextGenerationConfig(n=1, temperature=0.2, use_cache=True)
|
| 48 |
-
charts = lida.visualize(summary=summary, goal=goals[i], textgen_config=textgen_config, library=library)
|
| 49 |
-
image_base64 = charts[0].raster
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
save_image(image_base64, "filename.png")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|