Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
3 |
+
|
4 |
+
st.title("AI Accountant - Prompt-Based ERP Entry")
|
5 |
+
|
6 |
+
model_path = "./finetuned-flan-t5" # update if different path
|
7 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
8 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_path)
|
9 |
+
|
10 |
+
user_input = st.text_area("Enter accounting transaction:")
|
11 |
+
|
12 |
+
if st.button("Generate Entry"):
|
13 |
+
inputs = tokenizer(user_input, return_tensors="pt")
|
14 |
+
outputs = model.generate(**inputs, max_new_tokens=128)
|
15 |
+
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
16 |
+
st.json(eval(result)) # Convert JSON string to dict
|