Update main.py
Browse files
main.py
CHANGED
|
@@ -7,12 +7,12 @@ import pandas as pd
|
|
| 7 |
from io import StringIO
|
| 8 |
import os
|
| 9 |
|
| 10 |
-
from
|
| 11 |
-
|
| 12 |
-
|
| 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("/
|
| 27 |
-
async def
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 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 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|