-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathapp.py
More file actions
110 lines (91 loc) · 3.41 KB
/
app.py
File metadata and controls
110 lines (91 loc) · 3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/python3
"""
▄▄▄· ▄▄▌ ▄▄▄· ▄▄▄· ▄▄· ▄▄▄· ▄▄▄▄▄▄• ▄▌▄▄▄ ▄▄▄▄·
▐█ ▀█ ██• ▐█ ▄█▐█ ▀█ ▐█ ▌▪▐█ ▀█ •██ █▪██▌▀▄ █·▐█ ▀█▪▪
▄█▀▀█ ██▪ ██▀·▄█▀▀█ ██ ▄▄▄█▀▀█ ▐█.▪█▌▐█▌▐▀▀▄ ▐█▀▀█▄ ▄█▀▄
▐█ ▪▐▌▐█▌▐▌▐█▪·•▐█ ▪▐▌▐███▌▐█ ▪▐▌ ▐█▌·▐█▄█▌▐█•█▌██▄▪▐█▐█▌.▐▌
▀ ▀ .▀▀▀ .▀ ▀ ▀ ·▀▀▀ ▀ ▀ ▀▀▀ ▀▀▀ .▀ ▀·▀▀▀▀ ▀█▄▀▪
https;//github.comViperX7/Alpaca-Turbo
"""
import sys
import flet as ft
from alpaca_turbo import AIModel, Assistant
from flet import (ClipBehavior, Column, Container, CrossAxisAlignment, Image,
ListTile, MainAxisAlignment, Markdown, OutlinedButton, Page,
Row, Tab, Tabs, Text, alignment, border, colors)
from plugins.chatui import ChatUI
from plugins.completionui import CompletionUI
from plugins.model_editor import ModelManagerUI, SettingsManager
from rich import print as eprint
from utils.ui_elements import get_random_color, put_center
plugins = [
ChatUI,
CompletionUI,
SettingsManager,
]
def main(page: Page):
"""what do you expect the main function"""
page.horizontal_alignment = "center"
page.vertical_alignment = "center"
page.theme_mode = ft.ThemeMode.DARK
# page.window_height = 1000
# page.window_width = 1400
page.bgcolor = "#112233"
page.padding = 0
fab_actions = []
ui_units = {}
for plugin in plugins:
unit = plugin(page)
ui_units[unit.name] = unit.full_ui()
fab_actions.append(unit.fab())
tab_list = []
for name, screen in ui_units.items():
tab_list.append(
ft.Tab(
text=name,
content=Container(
bgcolor=get_random_color(),
# margin=ft.margin.only(top=10),
alignment=ft.alignment.center,
content=screen,
),
)
)
page.floating_action_button = fab_actions[0]
tab_changed = lambda _: [
setattr(
page, "floating_action_button", fab_actions[tabs.content.selected_index]
),
page.update(),
]
tabs = Container(
expand=True,
margin=0,
padding=0,
content=Tabs(
scrollable=True,
animation_duration=300,
tabs=tab_list,
on_change=tab_changed,
),
)
page.add(tabs)
page.title = "Alpaca Turbo"
page.update()
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description="Argument parser for web server")
parser.add_argument("--web", action="store_true", help="Enable web server")
parser.add_argument(
"--host", type=str, default="127.0.0.1", help="IP address to listen on"
)
parser.add_argument("--port", type=int, default=7887, help="Port to listen on")
args = parser.parse_args()
_ = ft.app(
target=main,
assets_dir="assets",
name="Alpaca Turbo",
host=args.host,
port=args.port,
view=ft.WEB_BROWSER if args.web else ft.FLET_APP,
)