ZeeAI1 commited on
Commit
f1441ea
·
verified ·
1 Parent(s): 2b46810

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +68 -0
app.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ from transformers import pipeline
4
+
5
+ # Initialize LLM pipeline
6
+ parser = pipeline("text2text-generation", model="google/flan-t5-base")
7
+
8
+ # Simulated chart of accounts mapping
9
+ account_map = {
10
+ "rent": "60001",
11
+ "utilities": "60002",
12
+ "cash": "10001",
13
+ "bank": "10002"
14
+ }
15
+
16
+ # Simulated business segments
17
+ segment = {
18
+ "company": "01",
19
+ "business_type": "102", # Grocery Store
20
+ "location": "001",
21
+ "cost_center": "001",
22
+ "future": "000"
23
+ }
24
+
25
+ def parse_prompt(prompt):
26
+ result = parser(f"Extract accounting entry: {prompt}")[0]['generated_text']
27
+ return result # Simplified: in real app, use structured parsing
28
+
29
+ def handle_gl_entry(prompt):
30
+ # Simulate parsing response
31
+ if "rent" in prompt.lower():
32
+ account_name = "rent"
33
+ amount = 500 # Normally extracted from LLM
34
+ else:
35
+ account_name = "utilities"
36
+ amount = 300
37
+
38
+ expense_account = account_map[account_name]
39
+ cash_account = account_map["cash"]
40
+
41
+ expense_account_code = f"{segment['company']}-{segment['business_type']}-{segment['location']}-{segment['cost_center']}-{expense_account}-{segment['future']}"
42
+ cash_account_code = f"{segment['company']}-{segment['business_type']}-{segment['location']}-{segment['cost_center']}-{cash_account}-{segment['future']}"
43
+
44
+ entry = pd.DataFrame([
45
+ {
46
+ "Date": "2025-04-01",
47
+ "Description": f"{account_name.title()} Expense",
48
+ "Account Code": expense_account_code,
49
+ "Debit": amount,
50
+ "Credit": 0
51
+ },
52
+ {
53
+ "Date": "2025-04-01",
54
+ "Description": f"Payment for {account_name}",
55
+ "Account Code": cash_account_code,
56
+ "Debit": 0,
57
+ "Credit": amount
58
+ }
59
+ ])
60
+ return entry
61
+
62
+ # Streamlit UI
63
+ st.title("AI ERP Chat - MVP")
64
+ prompt = st.text_input("Enter your accounting instruction:")
65
+
66
+ if prompt:
67
+ result = handle_gl_entry(prompt)
68
+ st.dataframe(result) # Show result as a DataFrame