| |
| import streamlit as st |
| from transformers import pipeline |
| from datetime import datetime |
| import uuid |
|
|
| |
| prompt_generator = pipeline("text-generation", model="gpt2") |
|
|
| |
| if 'transactions' not in st.session_state: |
| st.session_state.transactions = [] |
|
|
| |
| st.title("AI Prompt-based ERP System") |
|
|
| |
| st.sidebar.header("Business Setup") |
| company_name = st.sidebar.text_input("Company Name") |
| industry = st.sidebar.text_input("Industry") |
|
|
| if st.sidebar.button("Generate Chart of Accounts"): |
| coa_prompt = f"Generate a basic chart of accounts for a {industry} company named {company_name}." |
| coa = prompt_generator(coa_prompt, max_length=100, num_return_sequences=1)[0]['generated_text'] |
| st.sidebar.write("**Suggested Chart of Accounts:**") |
| st.sidebar.write(coa) |
|
|
| |
| st.header("Record a Transaction") |
| user_prompt = st.text_area("Describe your transaction (e.g., 'I paid $30,000 in shop tax today'):") |
|
|
| if st.button("Generate Accounting Entry") and user_prompt: |
| full_prompt = f"Create accounting entry from prompt: '{user_prompt}'" |
| generated_entry = prompt_generator(full_prompt, max_length=100, num_return_sequences=1)[0]['generated_text'] |
| |
| |
| transaction_id = str(uuid.uuid4())[:8] |
| |
| |
| transaction = { |
| "id": transaction_id, |
| "date": datetime.now().strftime("%Y-%m-%d"), |
| "description": user_prompt, |
| "entry": generated_entry |
| } |
|
|
| st.session_state.transactions.append(transaction) |
| st.success(f"Transaction recorded with ID: {transaction_id}") |
|
|
| |
| st.header("Transaction Records") |
| if st.session_state.transactions: |
| for trans in st.session_state.transactions: |
| st.subheader(f"Transaction ID: {trans['id']}") |
| st.write(f"**Date:** {trans['date']}") |
| st.write(f"**Description:** {trans['description']}") |
| st.write(f"**Generated Entry:** {trans['entry']}") |
| st.markdown("---") |
| else: |
| st.write("No transactions recorded yet.") |
|
|
| |
| if st.button("Clear All Transactions"): |
| st.session_state.transactions.clear() |
| st.warning("All transactions cleared.") |
|
|