АРХ - МЕЖПРОЕКТНАЯ КОММУНИКАЦИЯ: каркас Voice Tasker settings
This commit is contained in:
@@ -0,0 +1,187 @@
|
||||
# Generated by Codex on 2026-04-24
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
("db", "0123_force_profile_language_ru"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="WorkspaceAICredential",
|
||||
fields=[
|
||||
(
|
||||
"created_at",
|
||||
models.DateTimeField(auto_now_add=True, verbose_name="Created At"),
|
||||
),
|
||||
(
|
||||
"updated_at",
|
||||
models.DateTimeField(auto_now=True, verbose_name="Last Modified At"),
|
||||
),
|
||||
("deleted_at", models.DateTimeField(blank=True, editable=False, null=True)),
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
db_index=True,
|
||||
default=uuid.uuid4,
|
||||
editable=False,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
unique=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"provider",
|
||||
models.CharField(
|
||||
choices=[("openai", "OpenAI")],
|
||||
default="openai",
|
||||
max_length=32,
|
||||
),
|
||||
),
|
||||
("encrypted_api_key", models.TextField(blank=True)),
|
||||
("key_last4", models.CharField(blank=True, max_length=4)),
|
||||
("is_active", models.BooleanField(default=True)),
|
||||
(
|
||||
"created_by",
|
||||
models.ForeignKey(
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="%(class)s_created_by",
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
verbose_name="Created By",
|
||||
),
|
||||
),
|
||||
(
|
||||
"updated_by",
|
||||
models.ForeignKey(
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="%(class)s_updated_by",
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
verbose_name="Last Modified By",
|
||||
),
|
||||
),
|
||||
(
|
||||
"workspace",
|
||||
models.OneToOneField(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="ai_credential",
|
||||
to="db.workspace",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "Workspace AI Credential",
|
||||
"verbose_name_plural": "Workspace AI Credentials",
|
||||
"db_table": "workspace_ai_credentials",
|
||||
"ordering": ("-created_at",),
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="WorkspaceAISettings",
|
||||
fields=[
|
||||
(
|
||||
"created_at",
|
||||
models.DateTimeField(auto_now_add=True, verbose_name="Created At"),
|
||||
),
|
||||
(
|
||||
"updated_at",
|
||||
models.DateTimeField(auto_now=True, verbose_name="Last Modified At"),
|
||||
),
|
||||
("deleted_at", models.DateTimeField(blank=True, editable=False, null=True)),
|
||||
(
|
||||
"id",
|
||||
models.UUIDField(
|
||||
db_index=True,
|
||||
default=uuid.uuid4,
|
||||
editable=False,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
unique=True,
|
||||
),
|
||||
),
|
||||
("voice_tasker_enabled", models.BooleanField(default=False)),
|
||||
(
|
||||
"provider",
|
||||
models.CharField(
|
||||
choices=[("openai", "OpenAI")],
|
||||
default="openai",
|
||||
max_length=32,
|
||||
),
|
||||
),
|
||||
(
|
||||
"transcription_model",
|
||||
models.CharField(default="gpt-4o-mini-transcribe", max_length=80),
|
||||
),
|
||||
(
|
||||
"structuring_model",
|
||||
models.CharField(default="gpt-4o-mini", max_length=80),
|
||||
),
|
||||
(
|
||||
"access_mode",
|
||||
models.CharField(
|
||||
choices=[
|
||||
("all_workspace_members", "All workspace members"),
|
||||
("admins_only", "Admins only"),
|
||||
],
|
||||
default="all_workspace_members",
|
||||
max_length=40,
|
||||
),
|
||||
),
|
||||
("max_audio_duration_seconds", models.PositiveIntegerField(default=120)),
|
||||
("per_user_hourly_limit", models.PositiveIntegerField(default=30)),
|
||||
("workspace_hourly_limit", models.PositiveIntegerField(default=300)),
|
||||
(
|
||||
"created_by",
|
||||
models.ForeignKey(
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="%(class)s_created_by",
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
verbose_name="Created By",
|
||||
),
|
||||
),
|
||||
(
|
||||
"default_project",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="workspace_ai_default_project",
|
||||
to="db.project",
|
||||
),
|
||||
),
|
||||
(
|
||||
"updated_by",
|
||||
models.ForeignKey(
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name="%(class)s_updated_by",
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
verbose_name="Last Modified By",
|
||||
),
|
||||
),
|
||||
(
|
||||
"workspace",
|
||||
models.OneToOneField(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="ai_settings",
|
||||
to="db.workspace",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "Workspace AI Settings",
|
||||
"verbose_name_plural": "Workspace AI Settings",
|
||||
"db_table": "workspace_ai_settings",
|
||||
"ordering": ("-created_at",),
|
||||
},
|
||||
),
|
||||
]
|
||||
@@ -65,6 +65,7 @@ from .state import State, StateGroup, DEFAULT_STATES
|
||||
from .user import Account, Profile, User, BotTypeEnum
|
||||
from .view import IssueView
|
||||
from .webhook import Webhook, WebhookLog
|
||||
from .voice_tasker import WorkspaceAICredential, WorkspaceAISettings
|
||||
from .workspace import (
|
||||
Workspace,
|
||||
WorkspaceBaseModel,
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
# Copyright (c) 2023-present Plane Software, Inc. and contributors
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
# See the LICENSE file for details.
|
||||
|
||||
from django.db import models
|
||||
|
||||
from .base import BaseModel
|
||||
|
||||
|
||||
class WorkspaceAISettings(BaseModel):
|
||||
class Provider(models.TextChoices):
|
||||
OPENAI = "openai", "OpenAI"
|
||||
|
||||
class AccessMode(models.TextChoices):
|
||||
ALL_WORKSPACE_MEMBERS = "all_workspace_members", "All workspace members"
|
||||
ADMINS_ONLY = "admins_only", "Admins only"
|
||||
|
||||
workspace = models.OneToOneField(
|
||||
"db.Workspace",
|
||||
on_delete=models.CASCADE,
|
||||
related_name="ai_settings",
|
||||
)
|
||||
voice_tasker_enabled = models.BooleanField(default=False)
|
||||
provider = models.CharField(max_length=32, choices=Provider.choices, default=Provider.OPENAI)
|
||||
transcription_model = models.CharField(max_length=80, default="gpt-4o-mini-transcribe")
|
||||
structuring_model = models.CharField(max_length=80, default="gpt-4o-mini")
|
||||
default_project = models.ForeignKey(
|
||||
"db.Project",
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
blank=True,
|
||||
related_name="workspace_ai_default_project",
|
||||
)
|
||||
access_mode = models.CharField(
|
||||
max_length=40,
|
||||
choices=AccessMode.choices,
|
||||
default=AccessMode.ALL_WORKSPACE_MEMBERS,
|
||||
)
|
||||
max_audio_duration_seconds = models.PositiveIntegerField(default=120)
|
||||
per_user_hourly_limit = models.PositiveIntegerField(default=30)
|
||||
workspace_hourly_limit = models.PositiveIntegerField(default=300)
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Workspace AI Settings"
|
||||
verbose_name_plural = "Workspace AI Settings"
|
||||
db_table = "workspace_ai_settings"
|
||||
ordering = ("-created_at",)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.workspace.slug} AI settings"
|
||||
|
||||
|
||||
class WorkspaceAICredential(BaseModel):
|
||||
class Provider(models.TextChoices):
|
||||
OPENAI = "openai", "OpenAI"
|
||||
|
||||
workspace = models.OneToOneField(
|
||||
"db.Workspace",
|
||||
on_delete=models.CASCADE,
|
||||
related_name="ai_credential",
|
||||
)
|
||||
provider = models.CharField(max_length=32, choices=Provider.choices, default=Provider.OPENAI)
|
||||
encrypted_api_key = models.TextField(blank=True)
|
||||
key_last4 = models.CharField(max_length=4, blank=True)
|
||||
is_active = models.BooleanField(default=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Workspace AI Credential"
|
||||
verbose_name_plural = "Workspace AI Credentials"
|
||||
db_table = "workspace_ai_credentials"
|
||||
ordering = ("-created_at",)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.workspace.slug} {self.provider} credential"
|
||||
Reference in New Issue
Block a user