Skip to content

Commit

Permalink
chore: fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
elisalimli committed Mar 11, 2024
1 parent 5f243d1 commit aafe22b
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 23 deletions.
19 changes: 8 additions & 11 deletions api/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@
from typing import Dict

import aiohttp
from fastapi import APIRouter
from fastapi import APIRouter, status
from fastapi.responses import JSONResponse

from models.ingest import RequestPayload, TaskStatus
from models.api import ApiError
from models.ingest import RequestPayload, TaskStatus
from service.embedding import EmbeddingService
from service.ingest import handle_google_drive, handle_urls
from utils.summarise import SUMMARY_SUFFIX

from service.kafka.config import ingest_topic
from service.kafka.producer import kafka_producer
from service.redis.client import redis_client
from service.redis.ingest_task_manager import (
IngestTaskManager,
CreateTaskDto,
IngestTaskManager,
UpdateTaskDto,
)
from service.redis.client import redis_client

from fastapi.responses import JSONResponse
from fastapi import status
from service.kafka.config import kafka_bootstrap_servers, ingest_topic
from service.kafka.producer import kafka_producer
from utils.summarise import SUMMARY_SUFFIX

router = APIRouter()

Expand Down
3 changes: 2 additions & 1 deletion models/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pydantic import BaseModel
from typing import Optional

from pydantic import BaseModel


class ApiError(BaseModel):
message: Optional[str]
2 changes: 1 addition & 1 deletion models/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from pydantic import BaseModel, Field
from semantic_router.encoders import BaseEncoder, CohereEncoder, OpenAIEncoder

from models.api import ApiError
from models.file import File
from models.google_drive import GoogleDrive
from models.vector_database import VectorDatabase
from models.api import ApiError


class EncoderProvider(str, Enum):
Expand Down
1 change: 0 additions & 1 deletion service/kafka/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from decouple import config


ingest_topic = config("KAFKA_TOPIC_INGEST", default="ingestion")


Expand Down
10 changes: 5 additions & 5 deletions service/kafka/consume.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import asyncio
from api.ingest import ingest as _ingest, IngestPayload

from kafka.consumer.fetcher import ConsumerRecord

from service.redis.client import redis_client
from service.redis.ingest_task_manager import IngestTaskManager
from api.ingest import IngestPayload
from api.ingest import ingest as _ingest
from service.kafka.config import ingest_topic
from service.kafka.consumer import get_kafka_consumer

from kafka.consumer.fetcher import ConsumerRecord
from service.redis.client import redis_client
from service.redis.ingest_task_manager import IngestTaskManager


async def ingest(msg: ConsumerRecord):
Expand Down
4 changes: 3 additions & 1 deletion service/kafka/consumer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import json

from kafka import KafkaConsumer

from service.kafka.config import kafka_bootstrap_servers
import json


def get_kafka_consumer(topic: str):
Expand Down
3 changes: 2 additions & 1 deletion service/kafka/producer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from service.kafka.config import kafka_bootstrap_servers
from kafka import KafkaProducer

from service.kafka.config import kafka_bootstrap_servers

kafka_producer = KafkaProducer(bootstrap_servers=kafka_bootstrap_servers)
2 changes: 1 addition & 1 deletion service/redis/client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from redis import Redis
from decouple import config
from redis import Redis

redis_client = Redis(
host=config("REDIS_HOST", "localhost"), port=config("REDIS_PORT", 6379)
Expand Down
4 changes: 3 additions & 1 deletion service/redis/ingest_task_manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from redis import Redis
import json

from redis import Redis

from models.ingest import IngestTaskResponse


Expand Down

0 comments on commit aafe22b

Please sign in to comment.