Skip to content

Commit 07a1b49

Browse files
update persona defaults (#3042)
* evaluate None to default * fix usage report pagination * update persona defaults * update user preferences * k * validate * update typing * nit * formating nits * fallback to all assistants * update ux + spacing * udpate refresh logic * minor update to refresh * nit * touchup * update starter message * update default live assistant logic --------- Co-authored-by: Yuhong Sun <yuhongsun96@gmail.com>
1 parent 43d8daa commit 07a1b49

File tree

25 files changed

+533
-266
lines changed

25 files changed

+533
-266
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"""remove description from starter messages
2+
3+
Revision ID: b72ed7a5db0e
4+
Revises: 33cb72ea4d80
5+
Create Date: 2024-11-03 15:55:28.944408
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
11+
12+
# revision identifiers, used by Alembic.
13+
revision = "b72ed7a5db0e"
14+
down_revision = "33cb72ea4d80"
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade() -> None:
20+
op.execute(
21+
sa.text(
22+
"""
23+
UPDATE persona
24+
SET starter_messages = (
25+
SELECT jsonb_agg(elem - 'description')
26+
FROM jsonb_array_elements(starter_messages) elem
27+
)
28+
WHERE starter_messages IS NOT NULL
29+
"""
30+
)
31+
)
32+
33+
34+
def downgrade() -> None:
35+
op.execute(
36+
sa.text(
37+
"""
38+
UPDATE persona
39+
SET starter_messages = (
40+
SELECT jsonb_agg(elem || '{"description": ""}')
41+
FROM jsonb_array_elements(starter_messages) elem
42+
)
43+
WHERE starter_messages IS NOT NULL
44+
"""
45+
)
46+
)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""add recent assistants
2+
3+
Revision ID: c0fd6e4da83a
4+
Revises: b72ed7a5db0e
5+
Create Date: 2024-11-03 17:28:54.916618
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
from sqlalchemy.dialects import postgresql
11+
12+
# revision identifiers, used by Alembic.
13+
revision = "c0fd6e4da83a"
14+
down_revision = "b72ed7a5db0e"
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade() -> None:
20+
op.add_column(
21+
"user",
22+
sa.Column(
23+
"recent_assistants", postgresql.JSONB(), server_default="[]", nullable=False
24+
),
25+
)
26+
27+
28+
def downgrade() -> None:
29+
op.drop_column("user", "recent_assistants")

backend/danswer/chat/personas.yaml

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,14 @@ personas:
4242
display_priority: 1
4343
is_visible: true
4444
starter_messages:
45-
- name: "General Information"
46-
description: "Ask about available information"
47-
message: "Hello! I'm interested in learning more about the information available here. Could you give me an overview of the types of data or documents that might be accessible?"
48-
- name: "Specific Topic Search"
49-
description: "Search for specific information"
50-
message: "Hi! I'd like to learn more about a specific topic. Could you help me find relevant documents and information?"
51-
- name: "Recent Updates"
52-
description: "Inquire about latest additions"
53-
message: "Hello! I'm curious about any recent updates or additions to the knowledge base. Can you tell me what new information has been added lately?"
54-
- name: "Cross-referencing Information"
55-
description: "Connect information from different sources"
56-
message: "Hi! I'm working on a project that requires connecting information from multiple sources. How can I effectively cross-reference data across different documents or categories?"
45+
- name: "Give me an overview of what's here"
46+
message: "Sample some documents and tell me what you find."
47+
- name: "Use AI to solve a work related problem"
48+
message: "Ask me what problem I would like to solve, then search the knowledge base to help me find a solution."
49+
- name: "Find updates on a topic of interest"
50+
message: "Once I provide a topic, retrieve related documents and tell me when there was last activity on the topic if available."
51+
- name: "Surface contradictions"
52+
message: "Have me choose a subject. Once I have provided it, check against the knowledge base and point out any inconsistencies. For all your following responses, focus on identifying contradictions."
5753

5854
- id: 1
5955
name: "General"
@@ -71,18 +67,14 @@ personas:
7167
display_priority: 0
7268
is_visible: true
7369
starter_messages:
74-
- name: "Open Discussion"
75-
description: "Start an open-ended conversation"
76-
message: "Hi! Can you help me write a professional email?"
77-
- name: "Problem Solving"
78-
description: "Get help with a challenge"
79-
message: "Hello! I need help managing my daily tasks better. Do you have any simple tips?"
80-
- name: "Learn Something New"
81-
description: "Explore a new topic"
82-
message: "Hi! Could you explain what project management is in simple terms?"
83-
- name: "Creative Brainstorming"
84-
description: "Generate creative ideas"
85-
message: "Hello! I need to brainstorm some team building activities. Do you have any fun suggestions?"
70+
- name: "Summarize a document"
71+
message: "If I have provided a document please summarize it for me. If not, please ask me to upload a document either by dragging it into the input bar or clicking the +file icon."
72+
- name: "Help me with coding"
73+
message: 'Write me a "Hello World" script in 5 random languages to show off the functionality.'
74+
- name: "Draft a professional email"
75+
message: "Help me craft a professional email. Let's establish the context and the anticipated outcomes of the email before proposing a draft."
76+
- name: "Learn something new"
77+
message: "What is the difference between a Gantt chart, a Burndown chart and a Kanban board?"
8678

8779
- id: 2
8880
name: "Paraphrase"
@@ -101,16 +93,12 @@ personas:
10193
is_visible: false
10294
starter_messages:
10395
- name: "Document Search"
104-
description: "Find exact information"
10596
message: "Hi! Could you help me find information about our team structure and reporting lines from our internal documents?"
10697
- name: "Process Verification"
107-
description: "Find exact quotes"
10898
message: "Hello! I need to understand our project approval process. Could you find the exact steps from our documentation?"
10999
- name: "Technical Documentation"
110-
description: "Search technical details"
111100
message: "Hi there! I'm looking for information about our deployment procedures. Can you find the specific steps from our technical guides?"
112101
- name: "Policy Reference"
113-
description: "Check official policies"
114102
message: "Hello! Could you help me find our official guidelines about client communication? I need the exact wording from our documentation."
115103

116104
- id: 3
@@ -130,15 +118,11 @@ personas:
130118
display_priority: 3
131119
is_visible: true
132120
starter_messages:
133-
- name: "Landscape"
134-
description: "Generate a landscape image"
135-
message: "Create an image of a serene mountain lake at sunset, with snow-capped peaks reflected in the calm water and a small wooden cabin on the shore."
136-
- name: "Character"
137-
description: "Generate a character image"
138-
message: "Generate an image of a futuristic robot with glowing blue eyes, sleek metallic body, and intricate circuitry visible through transparent panels on its chest and arms."
139-
- name: "Abstract"
140-
description: "Create an abstract image"
141-
message: "Create an abstract image representing the concept of time, using swirling clock hands, fragmented hourglasses, and streaks of light to convey the passage of moments and eras."
142-
- name: "Urban Scene"
143-
description: "Generate an urban landscape"
144-
message: "Generate an image of a bustling futuristic cityscape at night, with towering skyscrapers, flying vehicles, holographic advertisements, and a mix of neon and bioluminescent lighting."
121+
- name: "Create visuals for a presentation"
122+
message: "Generate someone presenting a graph which clearly demonstrates an upwards trajectory."
123+
- name: "Find inspiration for a marketing campaign"
124+
message: "Generate an image of two happy individuals sipping on a soda drink in a glass bottle."
125+
- name: "Visualize a product design"
126+
message: "I want to add a search bar to my Iphone app. Generate me generic examples of how other apps implement this."
127+
- name: "Generate a humorous image response"
128+
message: "My teammate just made a silly mistake and I want to respond with a facepalm. Can you generate me one?"

backend/danswer/db/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ class User(SQLAlchemyBaseUserTableUUID, Base):
135135
hidden_assistants: Mapped[list[int]] = mapped_column(
136136
postgresql.JSONB(), nullable=False, default=[]
137137
)
138+
recent_assistants: Mapped[list[dict]] = mapped_column(
139+
postgresql.JSONB(), nullable=False, default=list, server_default="[]"
140+
)
138141

139142
oidc_expiry: Mapped[datetime.datetime] = mapped_column(
140143
TIMESTAMPAware(timezone=True), nullable=True
@@ -1321,7 +1324,6 @@ class StarterMessage(TypedDict):
13211324
in Postgres"""
13221325

13231326
name: str
1324-
description: str
13251327
message: str
13261328

13271329

backend/danswer/server/manage/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class UserPreferences(BaseModel):
4242
chosen_assistants: list[int] | None = None
4343
hidden_assistants: list[int] = []
4444
visible_assistants: list[int] = []
45-
45+
recent_assistants: list[int] | None = None
4646
default_model: str | None = None
4747

4848

backend/danswer/server/manage/users.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,59 @@ class ChosenDefaultModelRequest(BaseModel):
518518
default_model: str | None = None
519519

520520

521+
class RecentAssistantsRequest(BaseModel):
522+
current_assistant: int
523+
524+
525+
def update_recent_assistants(
526+
recent_assistants: list[int] | None, current_assistant: int
527+
) -> list[int]:
528+
if recent_assistants is None:
529+
recent_assistants = []
530+
else:
531+
recent_assistants = [x for x in recent_assistants if x != current_assistant]
532+
533+
# Add current assistant to start of list
534+
recent_assistants.insert(0, current_assistant)
535+
536+
# Keep only the 5 most recent assistants
537+
recent_assistants = recent_assistants[:5]
538+
return recent_assistants
539+
540+
541+
@router.patch("/user/recent-assistants")
542+
def update_user_recent_assistants(
543+
request: RecentAssistantsRequest,
544+
user: User | None = Depends(current_user),
545+
db_session: Session = Depends(get_session),
546+
) -> None:
547+
if user is None:
548+
if AUTH_TYPE == AuthType.DISABLED:
549+
store = get_kv_store()
550+
no_auth_user = fetch_no_auth_user(store)
551+
preferences = no_auth_user.preferences
552+
recent_assistants = preferences.recent_assistants
553+
updated_preferences = update_recent_assistants(
554+
recent_assistants, request.current_assistant
555+
)
556+
preferences.recent_assistants = updated_preferences
557+
set_no_auth_user_preferences(store, preferences)
558+
return
559+
else:
560+
raise RuntimeError("This should never happen")
561+
562+
recent_assistants = UserInfo.from_model(user).preferences.recent_assistants
563+
updated_recent_assistants = update_recent_assistants(
564+
recent_assistants, request.current_assistant
565+
)
566+
db_session.execute(
567+
update(User)
568+
.where(User.id == user.id) # type: ignore
569+
.values(recent_assistants=updated_recent_assistants)
570+
)
571+
db_session.commit()
572+
573+
521574
@router.patch("/user/default-model")
522575
def update_user_default_model(
523576
request: ChosenDefaultModelRequest,

deployment/cloud_kubernetes/workers/indexing_worker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kind: Deployment
33
metadata:
44
name: celery-worker-indexing
55
spec:
6-
replicas: 3
6+
replicas: 1
77
selector:
88
matchLabels:
99
app: celery-worker-indexing

deployment/cloud_kubernetes/workers/light_worker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kind: Deployment
33
metadata:
44
name: celery-worker-light
55
spec:
6-
replicas: 2
6+
replicas: 1
77
selector:
88
matchLabels:
99
app: celery-worker-light

web/src/app/admin/assistants/AssistantEditor.tsx

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,6 @@ export function AssistantEditor({
246246
name: Yup.string().required(
247247
"Each starter message must have a name"
248248
),
249-
description: Yup.string().required(
250-
"Each starter message must have a description"
251-
),
252249
message: Yup.string().required(
253250
"Each starter message must have a message"
254251
),
@@ -1053,36 +1050,6 @@ export function AssistantEditor({
10531050
/>
10541051
</div>
10551052

1056-
<div className="mt-3">
1057-
<Label small>Description</Label>
1058-
<SubLabel>
1059-
A description which tells the user
1060-
what they might want to use this
1061-
Starter Message for. For example
1062-
&quot;to a client about a new
1063-
feature&quot;
1064-
</SubLabel>
1065-
<Field
1066-
name={`starter_messages.${index}.description`}
1067-
className={`
1068-
border
1069-
border-border
1070-
bg-background
1071-
rounded
1072-
w-full
1073-
py-2
1074-
px-3
1075-
mr-4
1076-
`}
1077-
autoComplete="off"
1078-
/>
1079-
<ErrorMessage
1080-
name={`starter_messages[${index}].description`}
1081-
component="div"
1082-
className="text-error text-sm mt-1"
1083-
/>
1084-
</div>
1085-
10861053
<div className="mt-3">
10871054
<Label small>Message</Label>
10881055
<SubLabel>

web/src/app/admin/assistants/interfaces.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { DocumentSet, MinimalUserSnapshot } from "@/lib/types";
33

44
export interface StarterMessage {
55
name: string;
6-
description: string | null;
76
message: string;
87
}
98

0 commit comments

Comments
 (0)