Use Personality vernacular in agent page

- When setting up the default agent, configure every conversation that doesn't have an agent to use the Khoj agent
- Fix reverse migration for the locale removal migration
This commit is contained in:
sabaimran 2024-03-28 15:07:02 +05:30
parent e59de8c9b1
commit d503b3e867
3 changed files with 28 additions and 13 deletions

View file

@ -446,19 +446,21 @@ class AgentAdapters:
agent.slug = AgentAdapters.DEFAULT_AGENT_SLUG
agent.name = AgentAdapters.DEFAULT_AGENT_NAME
agent.save()
return agent
else:
# The default agent is public and managed by the admin. It's handled a little differently than other agents.
agent = Agent.objects.create(
name=AgentAdapters.DEFAULT_AGENT_NAME,
public=True,
managed_by_admin=True,
chat_model=default_conversation_config,
personality=default_personality,
tools=["*"],
avatar=AgentAdapters.DEFAULT_AGENT_AVATAR,
slug=AgentAdapters.DEFAULT_AGENT_SLUG,
)
Conversation.objects.filter(agent=None).update(agent=agent)
# The default agent is public and managed by the admin. It's handled a little differently than other agents.
return Agent.objects.create(
name=AgentAdapters.DEFAULT_AGENT_NAME,
public=True,
managed_by_admin=True,
chat_model=default_conversation_config,
personality=default_personality,
tools=["*"],
avatar=AgentAdapters.DEFAULT_AGENT_AVATAR,
slug=AgentAdapters.DEFAULT_AGENT_SLUG,
)
return agent
@staticmethod
async def aget_default_agent():

View file

@ -3,6 +3,18 @@
from django.db import migrations, models
def set_default_locale(apps, schema_editor):
return
def reverse_set_default_locale(apps, schema_editor):
GoogleUser = apps.get_model("database", "GoogleUser")
for user in GoogleUser.objects.all():
if not user.locale:
user.locale = "en"
user.save()
class Migration(migrations.Migration):
dependencies = [
("database", "0030_conversation_slug_and_title"),
@ -14,4 +26,5 @@ class Migration(migrations.Migration):
name="locale",
field=models.CharField(blank=True, default=None, max_length=200, null=True),
),
migrations.RunPython(set_default_locale, reverse_set_default_locale),
]

View file

@ -24,7 +24,7 @@
<img id="agent-avatar" src="{{ agent.avatar }}" alt="Agent Avatar">
<input type="text" id="agent-name-input" value="{{ agent.name }}" {% if agent.creator_not_self %} disabled {% endif %}>
</div>
<div id="agent-instructions">Instructions</div>
<div id="agent-instructions">Personality</div>
<div id="agent-tuning">
<p>{{ agent.personality }}</p>
</div>