mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 23:48:56 +01:00
Handle subscribe renew date, langchain, pydantic & logger.warn warnings
- Ensure langchain less than 0.2.0 is used, to prevent breaking ChatOpenAI, PyMuPDF usage due to their deprecation after 0.2.0 - Set subscription renewal date to a timezone aware datetime - Use logger.warning instead of logger.warn as latter is deprecated - Use `model_dump' not deprecated dict to get all configured content_types
This commit is contained in:
parent
5f97357fe0
commit
7dfbcd2e5a
6 changed files with 11 additions and 6 deletions
|
@ -55,7 +55,7 @@ dependencies = [
|
|||
"torch == 2.0.1",
|
||||
"uvicorn == 0.17.6",
|
||||
"aiohttp ~= 3.9.0",
|
||||
"langchain >= 0.0.331",
|
||||
"langchain <= 0.2.0",
|
||||
"requests >= 2.26.0",
|
||||
"bs4 >= 0.0.1",
|
||||
"anyio == 3.7.1",
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
import json
|
||||
import logging
|
||||
import os
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
from typing import Optional
|
||||
|
||||
import openai
|
||||
import requests
|
||||
import schedule
|
||||
from django.utils.timezone import make_aware
|
||||
from starlette.authentication import (
|
||||
AuthCredentials,
|
||||
AuthenticationBackend,
|
||||
|
@ -59,7 +61,8 @@ class UserAuthenticationBackend(AuthenticationBackend):
|
|||
email="default@example.com",
|
||||
password="default",
|
||||
)
|
||||
Subscription.objects.create(user=default_user, type="standard", renewal_date="2100-04-01")
|
||||
renewal_date = make_aware(datetime.strptime("2100-04-01", "%Y-%m-%d"))
|
||||
Subscription.objects.create(user=default_user, type="standard", renewal_date=renewal_date)
|
||||
|
||||
async def authenticate(self, request: HTTPConnection):
|
||||
current_user = request.session.get("user")
|
||||
|
|
|
@ -349,7 +349,7 @@ def get_config_types(
|
|||
configured_content_types = list(enabled_file_types)
|
||||
|
||||
if state.config and state.config.content_type:
|
||||
for ctype in state.config.content_type.dict(exclude_none=True):
|
||||
for ctype in state.config.content_type.model_dump(exclude_none=True):
|
||||
configured_content_types.append(ctype)
|
||||
|
||||
return [
|
||||
|
|
|
@ -26,7 +26,7 @@ logger = logging.getLogger(__name__)
|
|||
auth_router = APIRouter()
|
||||
|
||||
if not state.anonymous_mode and not (os.environ.get("GOOGLE_CLIENT_ID") and os.environ.get("GOOGLE_CLIENT_SECRET")):
|
||||
logger.warn(
|
||||
logger.warning(
|
||||
"🚨 Use --anonymous-mode flag to disable Google OAuth or set GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET environment variables to enable it"
|
||||
)
|
||||
else:
|
||||
|
|
|
@ -37,7 +37,7 @@ async def subscribe(request: Request):
|
|||
"customer.subscription.updated",
|
||||
"customer.subscription.deleted",
|
||||
}:
|
||||
logger.warn(f"Unhandled Stripe event type: {event['type']}")
|
||||
logger.warning(f"Unhandled Stripe event type: {event['type']}")
|
||||
return {"success": False}
|
||||
|
||||
# Retrieve the customer's details
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import os
|
||||
from datetime import datetime
|
||||
|
||||
import factory
|
||||
from django.utils.timezone import make_aware
|
||||
|
||||
from khoj.database.models import (
|
||||
ChatModelOptions,
|
||||
|
@ -90,4 +92,4 @@ class SubscriptionFactory(factory.django.DjangoModelFactory):
|
|||
user = factory.SubFactory(UserFactory)
|
||||
type = "standard"
|
||||
is_recurring = False
|
||||
renewal_date = "2100-04-01"
|
||||
renewal_date = make_aware(datetime.strptime("2100-04-01", "%Y-%m-%d"))
|
||||
|
|
Loading…
Reference in a new issue