Arafath10 commited on
Commit
a0778be
1 Parent(s): 582d451

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +11 -16
main.py CHANGED
@@ -7,12 +7,12 @@ import pandas as pd
7
  from io import StringIO
8
  import os
9
 
10
- from pandasai import SmartDataframe
11
- import pandas as pd
12
- from pandasai.llm import OpenAI
13
-
 
14
 
15
- secret = os.environ["key"]
16
 
17
  app = FastAPI()
18
  app.add_middleware(
@@ -23,14 +23,9 @@ app.add_middleware(
23
  allow_headers=["*"],
24
  )
25
 
26
- @app.post("/get_image_for_text")
27
- async def get_image_for_text(email,query,file: UploadFile = File(...)):
28
- print(file.filename)
29
- with open(email+".csv", "wb") as file_object:
30
- file_object.write(file.file.read())
31
- llm = OpenAI(api_token=secret,save_charts=True)
32
- df = pd.read_csv(email+".csv")
33
- sdf = SmartDataframe(df, config={"llm": llm})
34
- sdf.chat(query)
35
- image_path = "exports/charts/temp_chart.png" # Replace with your image's path
36
- return FileResponse(image_path)
 
7
  from io import StringIO
8
  import os
9
 
10
+ from llmlingua import PromptCompressor
11
+ llm_lingua = PromptCompressor(
12
+ model_name="microsoft/llmlingua-2-bert-base-multilingual-cased-meetingbank",
13
+ use_llmlingua2=True, # Whether to use llmlingua-2
14
+ )
15
 
 
16
 
17
  app = FastAPI()
18
  app.add_middleware(
 
23
  allow_headers=["*"],
24
  )
25
 
26
+ @app.post("/get_compressed_text")
27
+ async def get_compressed_text(original_propmt):
28
+ compressed_prompt = llm_lingua.compress_prompt(original_propmt, instruction="", question="")
29
+ print("compressed")
30
+ return compressed_prompt
31
+