2023-10-26 18:37:41 +00:00
|
|
|
import factory
|
|
|
|
import os
|
|
|
|
|
2023-11-21 18:56:04 +00:00
|
|
|
from khoj.database.models import (
|
2023-10-26 18:37:41 +00:00
|
|
|
KhojUser,
|
2023-10-26 19:33:03 +00:00
|
|
|
KhojApiUser,
|
2023-11-02 17:43:27 +00:00
|
|
|
ChatModelOptions,
|
2023-10-26 18:37:41 +00:00
|
|
|
OfflineChatProcessorConversationConfig,
|
|
|
|
OpenAIProcessorConversationConfig,
|
2023-11-16 01:12:54 +00:00
|
|
|
SearchModelConfig,
|
2023-11-02 17:43:27 +00:00
|
|
|
UserConversationConfig,
|
2023-10-26 18:37:41 +00:00
|
|
|
Conversation,
|
2023-11-11 06:38:28 +00:00
|
|
|
Subscription,
|
2023-10-26 18:37:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class UserFactory(factory.django.DjangoModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = KhojUser
|
|
|
|
|
|
|
|
username = factory.Faker("name")
|
|
|
|
email = factory.Faker("email")
|
|
|
|
password = factory.Faker("password")
|
|
|
|
uuid = factory.Faker("uuid4")
|
|
|
|
|
|
|
|
|
2023-10-26 19:33:03 +00:00
|
|
|
class ApiUserFactory(factory.django.DjangoModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = KhojApiUser
|
|
|
|
|
|
|
|
user = None
|
|
|
|
name = factory.Faker("name")
|
|
|
|
token = factory.Faker("password")
|
|
|
|
|
|
|
|
|
2023-11-02 17:43:27 +00:00
|
|
|
class ChatModelOptionsFactory(factory.django.DjangoModelFactory):
|
2023-10-26 18:37:41 +00:00
|
|
|
class Meta:
|
2023-11-02 17:43:27 +00:00
|
|
|
model = ChatModelOptions
|
2023-10-26 18:37:41 +00:00
|
|
|
|
|
|
|
max_prompt_size = 2000
|
|
|
|
tokenizer = None
|
2023-11-03 05:44:25 +00:00
|
|
|
chat_model = "mistral-7b-instruct-v0.1.Q4_0.gguf"
|
2023-11-02 17:43:27 +00:00
|
|
|
model_type = "offline"
|
|
|
|
|
|
|
|
|
|
|
|
class UserConversationProcessorConfigFactory(factory.django.DjangoModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = UserConversationConfig
|
|
|
|
|
|
|
|
user = factory.SubFactory(UserFactory)
|
|
|
|
setting = factory.SubFactory(ChatModelOptionsFactory)
|
2023-10-26 18:37:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
class OfflineChatProcessorConversationConfigFactory(factory.django.DjangoModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = OfflineChatProcessorConversationConfig
|
|
|
|
|
2023-11-02 17:43:27 +00:00
|
|
|
enabled = True
|
2023-10-26 18:37:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
class OpenAIProcessorConversationConfigFactory(factory.django.DjangoModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = OpenAIProcessorConversationConfig
|
|
|
|
|
|
|
|
api_key = os.getenv("OPENAI_API_KEY")
|
|
|
|
|
|
|
|
|
|
|
|
class ConversationFactory(factory.django.DjangoModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = Conversation
|
|
|
|
|
|
|
|
user = factory.SubFactory(UserFactory)
|
2023-11-11 06:38:28 +00:00
|
|
|
|
|
|
|
|
2023-11-15 00:56:26 +00:00
|
|
|
class SearchModelFactory(factory.django.DjangoModelFactory):
|
|
|
|
class Meta:
|
2023-11-16 01:12:54 +00:00
|
|
|
model = SearchModelConfig
|
2023-11-15 00:56:26 +00:00
|
|
|
|
|
|
|
name = "default"
|
|
|
|
model_type = "text"
|
|
|
|
bi_encoder = "thenlper/gte-small"
|
|
|
|
cross_encoder = "cross-encoder/ms-marco-MiniLM-L-6-v2"
|
|
|
|
|
|
|
|
|
2023-11-11 06:38:28 +00:00
|
|
|
class SubscriptionFactory(factory.django.DjangoModelFactory):
|
|
|
|
class Meta:
|
|
|
|
model = Subscription
|
|
|
|
|
|
|
|
user = factory.SubFactory(UserFactory)
|
2023-11-15 00:20:55 +00:00
|
|
|
type = "standard"
|
2023-11-11 06:38:28 +00:00
|
|
|
is_recurring = False
|
2023-11-15 00:20:55 +00:00
|
|
|
renewal_date = "2100-04-01"
|