Skip to content

Commit

Permalink
checkpoint update
Browse files Browse the repository at this point in the history
  • Loading branch information
ViperX7 committed Apr 14, 2023
1 parent 8e0ac27 commit 208cc29
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 19 deletions.
2 changes: 1 addition & 1 deletion turbo_server/ai_model_manager/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

# Register your models here.
data = [AIModelSettings,AIModel]
_ = [admin.register(mod) for mod in data]
_ = [admin.site.register(mod) for mod in data]
11 changes: 7 additions & 4 deletions turbo_server/ai_model_manager/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


class AIModelSettings(models.Model):
ai_model = models.ForeignKey("AIModel", on_delete=models.CASCADE)
name = models.CharField(max_length=255)
temperature = models.FloatField()
top_p = models.FloatField()
top_k = models.IntegerField()
Expand All @@ -18,10 +18,13 @@ class AIModelSettings(models.Model):


class AIModel(models.Model):
source = models.URLField()
model_format = models.CharField(max_length=255)
path = models.FilePathField(path="models")
name = models.CharField(max_length=255)
path = models.FilePathField()
source = models.URLField(blank=True, null=True)
model_format = models.CharField(max_length=255, blank=True, null=True)
settings = models.ForeignKey("AIModelSettings", on_delete=models.CASCADE)


@staticmethod
def list_all():
return AIModel.objects.all()
20 changes: 6 additions & 14 deletions turbo_server/chatbot/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ def remove_all_conv():
objs.delete()
return total


@staticmethod
def get_all_conversations():
conversations = Conversation.objects.all().values("id", "title", "created_at")
return list(conversations)

@property
def lastidx(self):
Expand Down Expand Up @@ -106,24 +109,13 @@ def add_message(

def append(self, message):
"""Append a new message to the conversation."""
index = 0
last_message = (
Message.objects.filter(conversation=self).order_by("-index").first()
)
if last_message:
index = last_message.index + 1
message.conversation = self
message.index = index
message.index = self.lastidx +1
message.save()
if index == 0:
if message.index == 0:
self.title = message.user_request
self.save()

@staticmethod
def get_all_conversations():
conversations = Conversation.objects.all().values("id", "title", "created_at")
return list(conversations)


class Message(models.Model):
"""Message model for a conversation"""
Expand Down
113 changes: 113 additions & 0 deletions turbo_server/model_editor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
from random import choice
from time import time

import flet as ft
from alpaca_turbo import Assistant
from flet import *
from flet import (ClipBehavior, Column, Container, CrossAxisAlignment, Image,
ListTile, MainAxisAlignment, Markdown, OutlinedButton, Page,
Row, Text, alignment, border, colors)
from rich import print as eprint

# from ai_model_manager.models import AIModel


class ModelManager:
"""UI to | Install | Configure | List | models"""

def __init__(self, page) -> None:
pass


def get_random_color():
return "#" + "".join([choice("0123456789ABCDEF") for _ in range(6)])


def easy_content_expander(content, vexpand=True, hexpand=True):
"""Simple function to expand stuff"""
obj = Row(
expand=vexpand,
controls=[
Container(
bgcolor=get_random_color(),
expand=hexpand,
content=Column(controls=[content]),
padding=ft.padding.only(top=20, bottom=20, left=20, right=20),
margin=0,
)
],
)

return obj


def main(page: Page):
page.horizontal_alignment = "center"
page.vertical_alignment = "center"
page.theme_mode = ft.ThemeMode.DARK
# page.window_height = 1000
# page.window_width = 1400
page.bgcolor = "black"
page.padding = 0
print("---")
print(page.window_height)
print(page.window_width)
print("---")

___main_content__ = Column(
expand=True,
alignment=MainAxisAlignment.CENTER,
horizontal_alignment=CrossAxisAlignment.CENTER,
spacing=0,
controls=[
easy_content_expander(
vexpand=False,
content=Column(
controls=[
Text("jiji"),
Text("jiji"),
Text("jiji"),
Text("jiji"),
]
),
),
easy_content_expander(Text("ok")),
],
)

# set-up-some-bg-and -main-container
# The-general-UI‘will-copy- that-of a-mobile-app
page.add(
# -this is just-a-bg-container
Container(
# width=1600,
# height=1000,
margin=0,
padding=0,
expand=True,
# margin=100,
bgcolor="blue",
alignment=alignment.center,
content=Row(
expand=True,
alignment=MainAxisAlignment.CENTER,
vertical_alignment=CrossAxisAlignment.CENTER,
controls=[
# main Container
Container(
expand=True,
bgcolor="#45323e",
# border_radius=40,
# border=border.all(0.5, "red"),
clip_behavior=ClipBehavior.HARD_EDGE,
content=___main_content__,
)
],
),
),
)

page.update()


ft.app(target=main, assets_dir="assets")

0 comments on commit 208cc29

Please sign in to comment.