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