ABC1 / app.py
ZeeAI1's picture
Update app.py
01497d7 verified
raw
history blame
2 kB
import streamlit as st
import pandas as pd
from huggingface_hub import InferenceClient
# Initialize hosted inference client
client = InferenceClient(model="google/flan-t5-base")
# Simulated chart of accounts mapping
account_map = {
"rent": "60001",
"utilities": "60002",
"cash": "10001",
"bank": "10002"
}
# Simulated business segments
segment = {
"company": "01",
"business_type": "102", # Grocery Store
"location": "001",
"cost_center": "001",
"future": "000"
}
def parse_prompt(prompt):
response = client.text_generation(prompt=f"Extract accounting entry: {prompt}", max_new_tokens=50)
return response
def handle_gl_entry(prompt):
# Simulate parsing response
if "rent" in prompt.lower():
account_name = "rent"
amount = 500 # Normally extracted from LLM
else:
account_name = "utilities"
amount = 300
expense_account = account_map[account_name]
cash_account = account_map["cash"]
expense_account_code = f"{segment['company']}-{segment['business_type']}-{segment['location']}-{segment['cost_center']}-{expense_account}-{segment['future']}"
cash_account_code = f"{segment['company']}-{segment['business_type']}-{segment['location']}-{segment['cost_center']}-{cash_account}-{segment['future']}"
entry = pd.DataFrame([
{
"Date": "2025-04-01",
"Description": f"{account_name.title()} Expense",
"Account Code": expense_account_code,
"Debit": amount,
"Credit": 0
},
{
"Date": "2025-04-01",
"Description": f"Payment for {account_name}",
"Account Code": cash_account_code,
"Debit": 0,
"Credit": amount
}
])
return entry
# Streamlit UI
st.title("AI ERP Chat - MVP")
prompt = st.text_input("Enter your accounting instruction:")
if prompt:
result = handle_gl_entry(prompt)
st.dataframe(result) # Show result as a DataFrame