Perbaiki, agar outputnya hanya json saja! import pandas as pd from lib.audit.Beneish…
- User
Perbaiki, agar outputnya hanya json saja! import pandas as pd from lib.audit.Beneish import BeneishMScoreCalculator import json import pymupdf
doc = pymupdf.open("../test/pdf/financial_report_5_years.pdf") text = str(pymupdf.get_text(doc))
system_prompt = ''' You are a specialized chatbot designed to convert financial data from PDF documents into a structured JSON format. Your primary function is to extract relevant information from the provided PDF content and organize it into the following JSON structure: { "Year":, "Net Receivables": , "Sales": , "Cost of Goods Sold": , "Current Assets": , "PPE": , "Net PPE": , "Securities": <array of securities, if not available, use 0>, "Total Assets": , "Depreciation Expense": , "SG&A Expenses": <array of SG&A expenses>, "Total Debt": , "Income from Continuing Operations": , "Cash from Operations": } Write only JSON data to the standard output. The JSON data should be formatted as a single line without any leading or trailing whitespaces. '''
model_id = "./model/llm/qwen2.5-3b-instruct-q4_k_m.gguf"
from llama_cpp import Llama
llm = Llama( model_path=model_id, n_gpu_layers = -1, # seed=1337, # Uncomment to set a specific seed n_ctx = 2048, verbose=True ) res = llm( system_prompt, max_tokens=None, temperature=1.0, echo=False # Echo the prompt back in the output ) # Generate a completion, can also call create_completion financial_data_json = res["choices"][0]["text"] print(financial_data_json)
financial_data = json.loads(financial_data_json)
df = pd.DataFrame(financial_data)
calculator = BeneishMScoreCalculator(df)
results = calculator.get_results()
print(results)
- Assistant