Buatkan lebih senior programmer lagi, Pisahkan ke lib agar seperti senior programmer!…
- User
Buatkan lebih senior programmer lagi, Pisahkan ke lib agar seperti senior programmer! Tuliskan semuanya ya agar professional! 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 without codeblock to the standard output. The JSON data should be formatted as a single line without any leading or trailing whitespaces. write "END" in new line to finish the conversation. '''
model_id = "./model/llm/14b/aidit-14b-instruct-q4_k_m-00001-of-00003.gguf" from llama_cpp import Llama
llm = Llama( model_path=model_id, n_gpu_layers = -1, n_ctx = 4096, verbose=True )
output = llm.create_completion( prompt=f"{system_prompt}\n{text}", echo=False, max_tokens=None, stream=True, stop=["END"], )
answer = "" for item in output: answer+=item['choices'][0]['text'] print(item['choices'][0]['text'], end='')
financial_data_json = answer financial_data = json.loads(financial_data_json) df = pd.DataFrame(financial_data)
calculator = BeneishMScoreCalculator(df)
results = calculator.get_results() print(results)
- Assistant