mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-06 13:22:12 +00:00
Dedupe, organize chat actor, director tests
- Move Chat actor tests that were previously in chat director tests file - Dedupe online, offline io selector chat actor tests
This commit is contained in:
@@ -15,6 +15,7 @@ from khoj.database.models import (
|
||||
Subscription,
|
||||
UserConversationConfig,
|
||||
)
|
||||
from khoj.processor.conversation.utils import message_to_log
|
||||
|
||||
|
||||
def get_chat_provider(default: ChatModelOptions.ModelType | None = ChatModelOptions.ModelType.OFFLINE):
|
||||
@@ -43,6 +44,19 @@ def get_chat_api_key(provider: ChatModelOptions.ModelType = None):
|
||||
return os.getenv("OPENAI_API_KEY") or os.getenv("GEMINI_API_KEY") or os.getenv("ANTHROPIC_API_KEY")
|
||||
|
||||
|
||||
def generate_chat_history(message_list):
|
||||
# Generate conversation logs
|
||||
conversation_log = {"chat": []}
|
||||
for user_message, chat_response, context in message_list:
|
||||
message_to_log(
|
||||
user_message,
|
||||
chat_response,
|
||||
{"context": context, "intent": {"query": user_message, "inferred-queries": f'["{user_message}"]'}},
|
||||
conversation_log=conversation_log.get("chat", []),
|
||||
)
|
||||
return conversation_log
|
||||
|
||||
|
||||
class UserFactory(factory.django.DjangoModelFactory):
|
||||
class Meta:
|
||||
model = KhojUser
|
||||
|
||||
Reference in New Issue
Block a user