mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-17 18:35:19 +02:00
Remove icon from prompts, update schemas for system prompt overrides
This commit is contained in:
parent
16f4d007e4
commit
329e979d48
5 changed files with 19 additions and 20 deletions
|
|
@ -1,4 +1,4 @@
|
|||
"""add system_prompt_slug to prompts
|
||||
"""add system_prompt_slug and drop icon from prompts
|
||||
|
||||
Revision ID: 113
|
||||
Revises: 112
|
||||
|
|
@ -16,7 +16,8 @@ depends_on: str | Sequence[str] | None = None
|
|||
|
||||
def upgrade() -> None:
|
||||
op.execute(
|
||||
"ALTER TABLE prompts ADD COLUMN IF NOT EXISTS system_prompt_slug VARCHAR(100)"
|
||||
"ALTER TABLE prompts ADD COLUMN IF NOT EXISTS"
|
||||
" system_prompt_slug VARCHAR(100)"
|
||||
)
|
||||
op.execute(
|
||||
"CREATE INDEX IF NOT EXISTS ix_prompts_system_prompt_slug"
|
||||
|
|
@ -26,9 +27,11 @@ def upgrade() -> None:
|
|||
"ALTER TABLE prompts ADD CONSTRAINT uq_prompt_user_system_slug"
|
||||
" UNIQUE (user_id, system_prompt_slug)"
|
||||
)
|
||||
op.execute("ALTER TABLE prompts DROP COLUMN IF EXISTS icon")
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.execute("ALTER TABLE prompts ADD COLUMN IF NOT EXISTS icon VARCHAR(50)")
|
||||
op.execute(
|
||||
"ALTER TABLE prompts DROP CONSTRAINT IF EXISTS uq_prompt_user_system_slug"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1806,7 +1806,6 @@ class Prompt(BaseModel, TimestampMixin):
|
|||
name = Column(String(200), nullable=False)
|
||||
prompt = Column(Text, nullable=False)
|
||||
mode = Column(SQLAlchemyEnum(PromptMode), nullable=False)
|
||||
icon = Column(String(50), nullable=True)
|
||||
is_public = Column(Boolean, nullable=False, default=False)
|
||||
|
||||
user = relationship("User")
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ SYSTEM_PROMPT_DEFAULTS: list[dict] = [
|
|||
" Return only the corrected text, nothing else.\n\n{selection}"
|
||||
),
|
||||
"mode": "transform",
|
||||
"icon": "check",
|
||||
},
|
||||
{
|
||||
"slug": "make-shorter",
|
||||
|
|
@ -17,7 +16,6 @@ SYSTEM_PROMPT_DEFAULTS: list[dict] = [
|
|||
" Return only the shortened text, nothing else.\n\n{selection}"
|
||||
),
|
||||
"mode": "transform",
|
||||
"icon": "minimize",
|
||||
},
|
||||
{
|
||||
"slug": "translate",
|
||||
|
|
@ -28,7 +26,6 @@ SYSTEM_PROMPT_DEFAULTS: list[dict] = [
|
|||
" Return only the translation, nothing else.\n\n{selection}"
|
||||
),
|
||||
"mode": "transform",
|
||||
"icon": "languages",
|
||||
},
|
||||
{
|
||||
"slug": "rewrite",
|
||||
|
|
@ -38,7 +35,6 @@ SYSTEM_PROMPT_DEFAULTS: list[dict] = [
|
|||
" Return only the rewritten text, nothing else.\n\n{selection}"
|
||||
),
|
||||
"mode": "transform",
|
||||
"icon": "pen-line",
|
||||
},
|
||||
{
|
||||
"slug": "summarize",
|
||||
|
|
@ -48,28 +44,24 @@ SYSTEM_PROMPT_DEFAULTS: list[dict] = [
|
|||
" Return only the summary, nothing else.\n\n{selection}"
|
||||
),
|
||||
"mode": "transform",
|
||||
"icon": "list",
|
||||
},
|
||||
{
|
||||
"slug": "explain",
|
||||
"name": "Explain",
|
||||
"prompt": "Explain the following text in simple terms:\n\n{selection}",
|
||||
"mode": "explore",
|
||||
"icon": "book-open",
|
||||
},
|
||||
{
|
||||
"slug": "ask-knowledge-base",
|
||||
"name": "Ask my knowledge base",
|
||||
"prompt": "Search my knowledge base for information related to:\n\n{selection}",
|
||||
"mode": "explore",
|
||||
"icon": "search",
|
||||
},
|
||||
{
|
||||
"slug": "look-up-web",
|
||||
"name": "Look up on the web",
|
||||
"prompt": "Search the web for information about:\n\n{selection}",
|
||||
"mode": "explore",
|
||||
"icon": "globe",
|
||||
},
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ async def create_prompt(
|
|||
name=body.name,
|
||||
prompt=body.prompt,
|
||||
mode=body.mode,
|
||||
icon=body.icon,
|
||||
)
|
||||
session.add(prompt)
|
||||
await session.commit()
|
||||
|
|
@ -138,7 +137,6 @@ async def copy_public_prompt(
|
|||
name=source.name,
|
||||
prompt=source.prompt,
|
||||
mode=source.mode,
|
||||
icon=source.icon,
|
||||
is_public=False,
|
||||
)
|
||||
session.add(copy)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
from datetime import datetime
|
||||
from typing import Literal
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
|
@ -7,7 +8,6 @@ class PromptCreate(BaseModel):
|
|||
name: str = Field(..., min_length=1, max_length=200)
|
||||
prompt: str = Field(..., min_length=1)
|
||||
mode: str = Field(..., pattern="^(transform|explore)$")
|
||||
icon: str | None = Field(None, max_length=50)
|
||||
search_space_id: int | None = None
|
||||
is_public: bool = False
|
||||
|
||||
|
|
@ -16,19 +16,26 @@ class PromptUpdate(BaseModel):
|
|||
name: str | None = Field(None, min_length=1, max_length=200)
|
||||
prompt: str | None = Field(None, min_length=1)
|
||||
mode: str | None = Field(None, pattern="^(transform|explore)$")
|
||||
icon: str | None = Field(None, max_length=50)
|
||||
is_public: bool | None = None
|
||||
|
||||
|
||||
class SystemPromptUpdate(BaseModel):
|
||||
name: str | None = Field(None, min_length=1, max_length=200)
|
||||
prompt: str | None = Field(None, min_length=1)
|
||||
mode: str | None = Field(None, pattern="^(transform|explore)$")
|
||||
|
||||
|
||||
class PromptRead(BaseModel):
|
||||
id: int
|
||||
id: int | None
|
||||
name: str
|
||||
prompt: str
|
||||
mode: str
|
||||
icon: str | None
|
||||
search_space_id: int | None
|
||||
is_public: bool
|
||||
created_at: datetime
|
||||
search_space_id: int | None = None
|
||||
is_public: bool = False
|
||||
created_at: datetime | None = None
|
||||
source: Literal["system", "custom"]
|
||||
system_prompt_slug: str | None = None
|
||||
is_modified: bool = False
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue