forked from khoj-ai/khoj
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Multi-User Part 3]: Separate chat sesssions based on authenticated u…
…sers (khoj-ai#511) - Add a data model which allows us to store Conversations with users. This does a minimal lift over the current setup, where the underlying data is stored in a JSON file. This maintains parity with that configuration. - There does _seem_ to be some regression in chat quality, which is most likely attributable to search results. This will help us with khoj-ai#275. It should become much easier to maintain multiple Conversations in a given table in the backend now. We will have to do some thinking on the UI.
- Loading branch information
Showing
24 changed files
with
716 additions
and
623 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
src/database/migrations/0007_remove_conversationprocessorconfig_conversation_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Generated by Django 4.2.5 on 2023-10-18 05:31 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("database", "0006_embeddingsdates"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name="conversationprocessorconfig", | ||
name="conversation", | ||
), | ||
migrations.RemoveField( | ||
model_name="conversationprocessorconfig", | ||
name="enable_offline_chat", | ||
), | ||
migrations.AddField( | ||
model_name="conversationprocessorconfig", | ||
name="max_prompt_size", | ||
field=models.IntegerField(blank=True, default=None, null=True), | ||
), | ||
migrations.AddField( | ||
model_name="conversationprocessorconfig", | ||
name="tokenizer", | ||
field=models.CharField(blank=True, default=None, max_length=200, null=True), | ||
), | ||
migrations.AddField( | ||
model_name="conversationprocessorconfig", | ||
name="user", | ||
field=models.ForeignKey( | ||
default=1, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL | ||
), | ||
preserve_default=False, | ||
), | ||
migrations.CreateModel( | ||
name="OpenAIProcessorConversationConfig", | ||
fields=[ | ||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), | ||
("created_at", models.DateTimeField(auto_now_add=True)), | ||
("updated_at", models.DateTimeField(auto_now=True)), | ||
("api_key", models.CharField(max_length=200)), | ||
("chat_model", models.CharField(max_length=200)), | ||
("user", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name="OfflineChatProcessorConversationConfig", | ||
fields=[ | ||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), | ||
("created_at", models.DateTimeField(auto_now_add=True)), | ||
("updated_at", models.DateTimeField(auto_now=True)), | ||
("enable_offline_chat", models.BooleanField(default=False)), | ||
("chat_model", models.CharField(default="llama-2-7b-chat.ggmlv3.q4_0.bin", max_length=200)), | ||
("user", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name="Conversation", | ||
fields=[ | ||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), | ||
("created_at", models.DateTimeField(auto_now_add=True)), | ||
("updated_at", models.DateTimeField(auto_now=True)), | ||
("conversation_log", models.JSONField()), | ||
("user", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
), | ||
] |
17 changes: 17 additions & 0 deletions
17
src/database/migrations/0008_alter_conversation_conversation_log.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Generated by Django 4.2.5 on 2023-10-18 16:46 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("database", "0007_remove_conversationprocessorconfig_conversation_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="conversation", | ||
name="conversation_log", | ||
field=models.JSONField(default=dict), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.