rijdev commited on
Commit
8237559
·
verified ·
1 Parent(s): ef1f90e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -0
app.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load an instruction-tuned model for text2text generation
5
+ generator = pipeline(
6
+ "text2text-generation",
7
+ model="google/flan-t5-small",
8
+ device=0 # set to -1 if you don’t have a GPU
9
+ )
10
+
11
+ def format_daily_plan(notes):
12
+ """
13
+ Takes a comma-separated list of notes/to-dos with optional times
14
+ and returns a structured plan:
15
+ - time-stamped events
16
+ - tasks list
17
+ """
18
+ # Build the prompt
19
+ prompt = (
20
+ "You are a personal assistant. "
21
+ "Convert these daily notes into a schedule and a task list.\n\n"
22
+ f"Notes: {notes}\n\n"
23
+ "Output format:\n"
24
+ "Today's Plan:\n\n"
25
+ "HH:MM AM/PM: Event description\n\n"
26
+ "Tasks: comma-separated list of remaining to-dos"
27
+ )
28
+
29
+ # Generate the formatted plan
30
+ output = generator(
31
+ prompt,
32
+ max_length=200,
33
+ do_sample=False
34
+ )[0]["generated_text"]
35
+
36
+ return output
37
+
38
+ # Gradio interface
39
+ iface = gr.Interface(
40
+ fn=format_daily_plan,
41
+ inputs=gr.Textbox(
42
+ lines=3,
43
+ placeholder="e.g. meeting at 9, lunch w/ Sarah, clean room, finish math hw, check bank acc, get groceries"
44
+ ),
45
+ outputs=gr.Textbox(label="Today's Plan"),
46
+ title="🗒️ Daily Notes → Structured Plan",
47
+ description=(
48
+ "Paste your comma-separated notes or to-do list; "
49
+ "the model will output a time-based schedule and a tasks list."
50
+ ),
51
+ theme="default"
52
+ )
53
+
54
+ if __name__ == "__main__":
55
+ iface.launch(server_name="0.0.0.0", server_port=7860)