From dc6bd5351945e6a256e26382b8f2a433e72520d2 Mon Sep 17 00:00:00 2001 From: Thoonsen Maxime Date: Fri, 19 Apr 2024 22:25:03 -1000 Subject: [PATCH] refactor: reorg files in backend (#2449) # Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate): ---- | :rocket: This description was created by [Ellipsis](https://www.ellipsis.dev) for commit 997576d577b9c0b3c5a00736096d1b51580b6227 | |--------| ### Summary: This PR involves a significant refactoring of the codebase, with file and class relocations and renames, and updated import paths, without introducing new functionality. **Key points**: - Significant refactoring of the codebase for improved organization and clarity. - File and class relocations and renames. - Updated import paths to reflect new locations and names. - No new functionality introduced. ---- Generated with :heart: by [ellipsis.dev](https://www.ellipsis.dev) --- backend/{repository => }/__init__.py | 0 backend/llm/__init__.py | 1 - backend/llm/prompts/CONDENSE_PROMPT.py | 9 --------- backend/models/__init__.py | 1 - backend/models/databases/{entity.py => llm_models.py} | 0 backend/models/databases/repository.py | 2 +- backend/models/databases/supabase/user_usage.py | 1 + backend/modules/assistant/ito/ito.py | 2 +- backend/modules/brain/api_brain_qa.py | 4 ++-- backend/modules/brain/controller/brain_routes.py | 4 ++-- .../brain/integrations/Notion/Notion_connector.py | 2 +- backend/modules/brain/knowledge_brain_qa.py | 10 +++++----- backend/modules/brain/qa_headless.py | 6 +++--- backend/modules/brain/rags/new_quivr_rag.py | 2 +- backend/modules/brain/rags/quivr_rag.py | 2 +- .../files => modules/brain/service}/__init__.py | 0 .../brain/service}/brain_subscription/__init__.py | 1 - .../brain_subscription/resend_invitation_email.py | 7 ++++++- .../subscription_invitation_service.py | 0 .../brain/service}/get_question_context_from_brain.py | 2 +- backend/modules/chat/controller/chat/utils.py | 4 ++-- backend/modules/chat/controller/chat_routes.py | 2 +- .../modules/knowledge/controller/knowledge_routes.py | 2 +- backend/modules/upload/controller/upload_routes.py | 2 +- .../upload/service/__init__.py} | 0 .../upload/service}/generate_file_signed_url.py | 0 .../files => modules/upload/service}/list_files.py | 0 .../files => modules/upload/service}/upload_file.py | 0 backend/modules/user/__init__.py | 0 backend/{models => modules/user/service}/user_usage.py | 0 backend/packages/files/parsers/common.py | 2 +- backend/repository/brain/__init__.py | 1 - backend/repository/brain_subscription/get_brain_url.py | 8 -------- backend/routes/subscription_routes.py | 2 +- backend/tests/ragas_evaluation/run_evaluation.py | 2 +- backend/{llm => }/utils/call_brain_api.py | 4 ++-- ...ract_api_brain_definition_values_from_llm_output.py | 0 backend/{llm => }/utils/extract_api_definition.py | 0 backend/{llm => }/utils/format_chat_history.py | 0 .../utils/get_api_brain_definition_as_json_schema.py | 4 ++-- backend/{llm => }/utils/get_prompt_to_use.py | 2 +- backend/{llm => }/utils/get_prompt_to_use_id.py | 0 backend/{llm => }/utils/make_api_request.py | 0 backend/{llm => }/utils/sanitize_function_name.py | 0 44 files changed, 38 insertions(+), 53 deletions(-) rename backend/{repository => }/__init__.py (100%) delete mode 100644 backend/llm/__init__.py delete mode 100644 backend/llm/prompts/CONDENSE_PROMPT.py rename backend/models/databases/{entity.py => llm_models.py} (100%) rename backend/{repository/files => modules/brain/service}/__init__.py (100%) rename backend/{repository => modules/brain/service}/brain_subscription/__init__.py (76%) rename backend/{repository => modules/brain/service}/brain_subscription/resend_invitation_email.py (89%) rename backend/{repository => modules/brain/service}/brain_subscription/subscription_invitation_service.py (100%) rename backend/{repository/brain => modules/brain/service}/get_question_context_from_brain.py (95%) rename backend/{llm/tests/test_knowledge_brain_qa.py => modules/upload/service/__init__.py} (100%) rename backend/{repository/files => modules/upload/service}/generate_file_signed_url.py (100%) rename backend/{repository/files => modules/upload/service}/list_files.py (100%) rename backend/{repository/files => modules/upload/service}/upload_file.py (100%) create mode 100644 backend/modules/user/__init__.py rename backend/{models => modules/user/service}/user_usage.py (100%) delete mode 100644 backend/repository/brain/__init__.py delete mode 100644 backend/repository/brain_subscription/get_brain_url.py rename backend/{llm => }/utils/call_brain_api.py (91%) rename backend/{llm => }/utils/extract_api_brain_definition_values_from_llm_output.py (100%) rename backend/{llm => }/utils/extract_api_definition.py (100%) rename backend/{llm => }/utils/format_chat_history.py (100%) rename backend/{llm => }/utils/get_api_brain_definition_as_json_schema.py (89%) rename backend/{llm => }/utils/get_prompt_to_use.py (86%) rename backend/{llm => }/utils/get_prompt_to_use_id.py (100%) rename backend/{llm => }/utils/make_api_request.py (100%) rename backend/{llm => }/utils/sanitize_function_name.py (100%) diff --git a/backend/repository/__init__.py b/backend/__init__.py similarity index 100% rename from backend/repository/__init__.py rename to backend/__init__.py diff --git a/backend/llm/__init__.py b/backend/llm/__init__.py deleted file mode 100644 index 8b1378917..000000000 --- a/backend/llm/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/backend/llm/prompts/CONDENSE_PROMPT.py b/backend/llm/prompts/CONDENSE_PROMPT.py deleted file mode 100644 index 5d1b24ae0..000000000 --- a/backend/llm/prompts/CONDENSE_PROMPT.py +++ /dev/null @@ -1,9 +0,0 @@ -from langchain.prompts.prompt import PromptTemplate - -_template = """Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question, in its original language. include the follow up instructions in the standalone question. - -Chat History: -{chat_history} -Follow Up Input: {question} -Standalone question:""" -CONDENSE_QUESTION_PROMPT = PromptTemplate.from_template(_template) diff --git a/backend/models/__init__.py b/backend/models/__init__.py index fda320434..9a53a8e6d 100644 --- a/backend/models/__init__.py +++ b/backend/models/__init__.py @@ -3,4 +3,3 @@ from .files import File from .settings import (BrainRateLimiting, BrainSettings, ResendSettings, get_documents_vector_store, get_embeddings, get_supabase_client, get_supabase_db) -from .user_usage import UserUsage diff --git a/backend/models/databases/entity.py b/backend/models/databases/llm_models.py similarity index 100% rename from backend/models/databases/entity.py rename to backend/models/databases/llm_models.py diff --git a/backend/models/databases/repository.py b/backend/models/databases/repository.py index 62c5c4551..1c473ff75 100644 --- a/backend/models/databases/repository.py +++ b/backend/models/databases/repository.py @@ -2,7 +2,7 @@ from abc import ABC, abstractmethod from datetime import datetime from uuid import UUID -from .entity import LLMModels +from .llm_models import LLMModels class Repository(ABC): diff --git a/backend/models/databases/supabase/user_usage.py b/backend/models/databases/supabase/user_usage.py index 767d3af9b..9e69038ec 100644 --- a/backend/models/databases/supabase/user_usage.py +++ b/backend/models/databases/supabase/user_usage.py @@ -7,6 +7,7 @@ from models.databases.repository import Repository logger = get_logger(__name__) +#TODO: change the name of this class because another one already exists class UserUsage(Repository): def __init__(self, supabase_client): self.db = supabase_client diff --git a/backend/modules/assistant/ito/ito.py b/backend/modules/assistant/ito/ito.py index 3cdcf3f29..0a92fbb5f 100644 --- a/backend/modules/assistant/ito/ito.py +++ b/backend/modules/assistant/ito/ito.py @@ -9,7 +9,7 @@ from typing import List, Optional from fastapi import UploadFile from logger import get_logger -from models.user_usage import UserUsage +from modules.user.service.user_usage import UserUsage from modules.assistant.dto.inputs import InputAssistant from modules.assistant.ito.utils.pdf_generator import PDFGenerator, PDFModel from modules.chat.controller.chat.utils import update_user_usage diff --git a/backend/modules/brain/api_brain_qa.py b/backend/modules/brain/api_brain_qa.py index 9b5677c42..411044a56 100644 --- a/backend/modules/brain/api_brain_qa.py +++ b/backend/modules/brain/api_brain_qa.py @@ -6,8 +6,8 @@ import jq import requests from fastapi import HTTPException from litellm import completion -from llm.utils.call_brain_api import call_brain_api -from llm.utils.get_api_brain_definition_as_json_schema import ( +from utils.call_brain_api import call_brain_api +from utils.get_api_brain_definition_as_json_schema import ( get_api_brain_definition_as_json_schema, ) from logger import get_logger diff --git a/backend/modules/brain/controller/brain_routes.py b/backend/modules/brain/controller/brain_routes.py index 480e5e88e..df70c94a9 100644 --- a/backend/modules/brain/controller/brain_routes.py +++ b/backend/modules/brain/controller/brain_routes.py @@ -4,7 +4,6 @@ from uuid import UUID from fastapi import APIRouter, Depends, HTTPException from logger import get_logger from middlewares.auth.auth_bearer import AuthBearer, get_current_user -from models import UserUsage from modules.brain.dto.inputs import ( BrainQuestionRequest, BrainUpdatableProperties, @@ -15,13 +14,14 @@ from modules.brain.entity.integration_brain import IntegrationDescriptionEntity from modules.brain.service.brain_authorization_service import has_brain_authorization from modules.brain.service.brain_service import BrainService from modules.brain.service.brain_user_service import BrainUserService +from modules.brain.service.get_question_context_from_brain import get_question_context_from_brain from modules.brain.service.integration_brain_service import ( IntegrationBrainDescriptionService, ) from modules.prompt.service.prompt_service import PromptService from modules.user.entity.user_identity import UserIdentity +from modules.user.service.user_usage import UserUsage from packages.utils.telemetry import maybe_send_telemetry -from repository.brain import get_question_context_from_brain logger = get_logger(__name__) brain_router = APIRouter() diff --git a/backend/modules/brain/integrations/Notion/Notion_connector.py b/backend/modules/brain/integrations/Notion/Notion_connector.py index 72d3d5341..013d054b7 100644 --- a/backend/modules/brain/integrations/Notion/Notion_connector.py +++ b/backend/modules/brain/integrations/Notion/Notion_connector.py @@ -14,7 +14,7 @@ from modules.knowledge.dto.inputs import CreateKnowledgeProperties from modules.knowledge.repository.knowledge_interface import KnowledgeInterface from modules.knowledge.service.knowledge_service import KnowledgeService from pydantic import BaseModel -from repository.files.upload_file import upload_file_storage +from modules.upload.service.upload_file import upload_file_storage logger = get_logger(__name__) diff --git a/backend/modules/brain/knowledge_brain_qa.py b/backend/modules/brain/knowledge_brain_qa.py index a7fd7a679..de0bdc91f 100644 --- a/backend/modules/brain/knowledge_brain_qa.py +++ b/backend/modules/brain/knowledge_brain_qa.py @@ -3,12 +3,12 @@ from typing import AsyncIterable, List, Optional from uuid import UUID from langchain.callbacks.streaming_aiter import AsyncIteratorCallbackHandler -from llm.utils.format_chat_history import format_chat_history -from llm.utils.get_prompt_to_use import get_prompt_to_use -from llm.utils.get_prompt_to_use_id import get_prompt_to_use_id +from utils.format_chat_history import format_chat_history +from utils.get_prompt_to_use import get_prompt_to_use +from utils.get_prompt_to_use_id import get_prompt_to_use_id from logger import get_logger from models import BrainSettings -from models.user_usage import UserUsage +from modules.user.service.user_usage import UserUsage from modules.brain.entity.brain_entity import BrainEntity from modules.brain.qa_interface import QAInterface from modules.brain.rags.quivr_rag import QuivrRAG @@ -24,7 +24,7 @@ from modules.chat.dto.outputs import GetChatHistoryOutput from modules.chat.service.chat_service import ChatService from pydantic import BaseModel, ConfigDict from pydantic_settings import BaseSettings -from repository.files.generate_file_signed_url import generate_file_signed_url +from modules.upload.service.generate_file_signed_url import generate_file_signed_url logger = get_logger(__name__) QUIVR_DEFAULT_PROMPT = "Your name is Quivr. You're a helpful assistant. If you don't know the answer, just say that you don't know, don't try to make up an answer." diff --git a/backend/modules/brain/qa_headless.py b/backend/modules/brain/qa_headless.py index 2ef54082d..3effdf1b9 100644 --- a/backend/modules/brain/qa_headless.py +++ b/backend/modules/brain/qa_headless.py @@ -8,12 +8,12 @@ from langchain.chains import LLMChain from langchain.chat_models.base import BaseChatModel from langchain.prompts.chat import ChatPromptTemplate, HumanMessagePromptTemplate from langchain_community.chat_models import ChatLiteLLM -from llm.utils.format_chat_history import ( +from utils.format_chat_history import ( format_chat_history, format_history_to_openai_mesages, ) -from llm.utils.get_prompt_to_use import get_prompt_to_use -from llm.utils.get_prompt_to_use_id import get_prompt_to_use_id +from utils.get_prompt_to_use import get_prompt_to_use +from utils.get_prompt_to_use_id import get_prompt_to_use_id from logger import get_logger from models import BrainSettings # Importing settings related to the 'brain' from modules.brain.qa_interface import QAInterface diff --git a/backend/modules/brain/rags/new_quivr_rag.py b/backend/modules/brain/rags/new_quivr_rag.py index d09fb7058..720a4d7d8 100644 --- a/backend/modules/brain/rags/new_quivr_rag.py +++ b/backend/modules/brain/rags/new_quivr_rag.py @@ -12,7 +12,7 @@ from langchain_core.output_parsers import StrOutputParser from langchain_core.prompts import ChatPromptTemplate, PromptTemplate from langchain_core.runnables import RunnableParallel, RunnablePassthrough from langchain_openai import ChatOpenAI, OpenAIEmbeddings -from llm.utils.get_prompt_to_use import get_prompt_to_use +from utils.get_prompt_to_use import get_prompt_to_use from logger import get_logger from models import BrainSettings # Importing settings related to the 'brain' from modules.brain.service.brain_service import BrainService diff --git a/backend/modules/brain/rags/quivr_rag.py b/backend/modules/brain/rags/quivr_rag.py index a7f026013..526200cde 100644 --- a/backend/modules/brain/rags/quivr_rag.py +++ b/backend/modules/brain/rags/quivr_rag.py @@ -14,7 +14,7 @@ from langchain_core.output_parsers import StrOutputParser from langchain_core.prompts import ChatPromptTemplate, PromptTemplate from langchain_core.runnables import RunnableLambda, RunnablePassthrough from langchain_openai import OpenAIEmbeddings -from llm.utils.get_prompt_to_use import get_prompt_to_use +from utils.get_prompt_to_use import get_prompt_to_use from logger import get_logger from models import BrainSettings # Importing settings related to the 'brain' from modules.brain.service.brain_service import BrainService diff --git a/backend/repository/files/__init__.py b/backend/modules/brain/service/__init__.py similarity index 100% rename from backend/repository/files/__init__.py rename to backend/modules/brain/service/__init__.py diff --git a/backend/repository/brain_subscription/__init__.py b/backend/modules/brain/service/brain_subscription/__init__.py similarity index 76% rename from backend/repository/brain_subscription/__init__.py rename to backend/modules/brain/service/brain_subscription/__init__.py index 2eae654b4..efe9797fc 100644 --- a/backend/repository/brain_subscription/__init__.py +++ b/backend/modules/brain/service/brain_subscription/__init__.py @@ -1,3 +1,2 @@ -from .get_brain_url import get_brain_url from .resend_invitation_email import resend_invitation_email from .subscription_invitation_service import SubscriptionInvitationService diff --git a/backend/repository/brain_subscription/resend_invitation_email.py b/backend/modules/brain/service/brain_subscription/resend_invitation_email.py similarity index 89% rename from backend/repository/brain_subscription/resend_invitation_email.py rename to backend/modules/brain/service/brain_subscription/resend_invitation_email.py index cc2048a56..c2deb533f 100644 --- a/backend/repository/brain_subscription/resend_invitation_email.py +++ b/backend/modules/brain/service/brain_subscription/resend_invitation_email.py @@ -4,13 +4,18 @@ from logger import get_logger from models import BrainSettings, BrainSubscription from modules.brain.service.brain_service import BrainService from packages.emails.send_email import send_email -from repository.brain_subscription import get_brain_url logger = get_logger(__name__) brain_service = BrainService() +def get_brain_url(origin: str, brain_id: UUID) -> str: + """Generates the brain URL based on the brain_id.""" + + return f"{origin}/invitation/{brain_id}" + + def resend_invitation_email( brain_subscription: BrainSubscription, inviter_email: str, diff --git a/backend/repository/brain_subscription/subscription_invitation_service.py b/backend/modules/brain/service/brain_subscription/subscription_invitation_service.py similarity index 100% rename from backend/repository/brain_subscription/subscription_invitation_service.py rename to backend/modules/brain/service/brain_subscription/subscription_invitation_service.py diff --git a/backend/repository/brain/get_question_context_from_brain.py b/backend/modules/brain/service/get_question_context_from_brain.py similarity index 95% rename from backend/repository/brain/get_question_context_from_brain.py rename to backend/modules/brain/service/get_question_context_from_brain.py index 14eca2c96..da7b9aa44 100644 --- a/backend/repository/brain/get_question_context_from_brain.py +++ b/backend/modules/brain/service/get_question_context_from_brain.py @@ -3,7 +3,7 @@ from uuid import UUID from attr import dataclass from logger import get_logger from models.settings import get_embeddings, get_supabase_client -from repository.files.generate_file_signed_url import generate_file_signed_url +from modules.upload.service.generate_file_signed_url import generate_file_signed_url from vectorstore.supabase import CustomSupabaseVectorStore logger = get_logger(__name__) diff --git a/backend/modules/chat/controller/chat/utils.py b/backend/modules/chat/controller/chat/utils.py index 7fe8eba81..ea7eee95a 100644 --- a/backend/modules/chat/controller/chat/utils.py +++ b/backend/modules/chat/controller/chat/utils.py @@ -3,10 +3,10 @@ from uuid import UUID from fastapi import HTTPException from logger import get_logger -from models import UserUsage -from models.databases.entity import LLMModels +from models.databases.llm_models import LLMModels from modules.brain.service.brain_service import BrainService from modules.chat.service.chat_service import ChatService +from modules.user.service.user_usage import UserUsage logger = get_logger(__name__) brain_service = BrainService() diff --git a/backend/modules/chat/controller/chat_routes.py b/backend/modules/chat/controller/chat_routes.py index 6b0fa0b4a..535e8a8e4 100644 --- a/backend/modules/chat/controller/chat_routes.py +++ b/backend/modules/chat/controller/chat_routes.py @@ -8,7 +8,7 @@ from langchain_openai import OpenAIEmbeddings from logger import get_logger from middlewares.auth import AuthBearer, get_current_user from models.settings import BrainSettings, get_supabase_client -from models.user_usage import UserUsage +from modules.user.service.user_usage import UserUsage from modules.brain.service.brain_service import BrainService from modules.chat.controller.chat.brainful_chat import BrainfulChat from modules.chat.dto.chats import ChatItem, ChatQuestion diff --git a/backend/modules/knowledge/controller/knowledge_routes.py b/backend/modules/knowledge/controller/knowledge_routes.py index b8d09b26e..98e282b31 100644 --- a/backend/modules/knowledge/controller/knowledge_routes.py +++ b/backend/modules/knowledge/controller/knowledge_routes.py @@ -11,7 +11,7 @@ from modules.brain.service.brain_authorization_service import ( from modules.brain.service.brain_vector_service import BrainVectorService from modules.knowledge.service.knowledge_service import KnowledgeService from modules.user.entity.user_identity import UserIdentity -from repository.files.generate_file_signed_url import generate_file_signed_url +from modules.upload.service.generate_file_signed_url import generate_file_signed_url knowledge_router = APIRouter() logger = get_logger(__name__) diff --git a/backend/modules/upload/controller/upload_routes.py b/backend/modules/upload/controller/upload_routes.py index 0345daa0c..c7086fc47 100644 --- a/backend/modules/upload/controller/upload_routes.py +++ b/backend/modules/upload/controller/upload_routes.py @@ -22,7 +22,7 @@ from modules.notification.service.notification_service import NotificationServic from modules.user.entity.user_identity import UserIdentity from packages.files.file import convert_bytes, get_file_size from packages.utils.telemetry import maybe_send_telemetry -from repository.files.upload_file import upload_file_storage +from modules.upload.service.upload_file import upload_file_storage logger = get_logger(__name__) upload_router = APIRouter() diff --git a/backend/llm/tests/test_knowledge_brain_qa.py b/backend/modules/upload/service/__init__.py similarity index 100% rename from backend/llm/tests/test_knowledge_brain_qa.py rename to backend/modules/upload/service/__init__.py diff --git a/backend/repository/files/generate_file_signed_url.py b/backend/modules/upload/service/generate_file_signed_url.py similarity index 100% rename from backend/repository/files/generate_file_signed_url.py rename to backend/modules/upload/service/generate_file_signed_url.py diff --git a/backend/repository/files/list_files.py b/backend/modules/upload/service/list_files.py similarity index 100% rename from backend/repository/files/list_files.py rename to backend/modules/upload/service/list_files.py diff --git a/backend/repository/files/upload_file.py b/backend/modules/upload/service/upload_file.py similarity index 100% rename from backend/repository/files/upload_file.py rename to backend/modules/upload/service/upload_file.py diff --git a/backend/modules/user/__init__.py b/backend/modules/user/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/backend/models/user_usage.py b/backend/modules/user/service/user_usage.py similarity index 100% rename from backend/models/user_usage.py rename to backend/modules/user/service/user_usage.py diff --git a/backend/packages/files/parsers/common.py b/backend/packages/files/parsers/common.py index d439d8808..379566c6b 100644 --- a/backend/packages/files/parsers/common.py +++ b/backend/packages/files/parsers/common.py @@ -5,7 +5,7 @@ from logger import get_logger from models import File from modules.brain.service.brain_vector_service import BrainVectorService from packages.embeddings.vectors import Neurons -from repository.files.upload_file import DocumentSerializable +from modules.upload.service.upload_file import DocumentSerializable logger = get_logger(__name__) diff --git a/backend/repository/brain/__init__.py b/backend/repository/brain/__init__.py deleted file mode 100644 index 408a2528a..000000000 --- a/backend/repository/brain/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .get_question_context_from_brain import get_question_context_from_brain diff --git a/backend/repository/brain_subscription/get_brain_url.py b/backend/repository/brain_subscription/get_brain_url.py deleted file mode 100644 index cf01199aa..000000000 --- a/backend/repository/brain_subscription/get_brain_url.py +++ /dev/null @@ -1,8 +0,0 @@ -import os -from uuid import UUID - - -def get_brain_url(origin: str, brain_id: UUID) -> str: - """Generates the brain URL based on the brain_id.""" - - return f"{origin}/invitation/{brain_id}" diff --git a/backend/routes/subscription_routes.py b/backend/routes/subscription_routes.py index 1b50075f3..c864e37a7 100644 --- a/backend/routes/subscription_routes.py +++ b/backend/routes/subscription_routes.py @@ -17,7 +17,7 @@ from modules.prompt.service.prompt_service import PromptService from modules.user.entity.user_identity import UserIdentity from modules.user.service.user_service import UserService from pydantic import BaseModel -from repository.brain_subscription import ( +from modules.brain.service.brain_subscription import ( SubscriptionInvitationService, resend_invitation_email, ) diff --git a/backend/tests/ragas_evaluation/run_evaluation.py b/backend/tests/ragas_evaluation/run_evaluation.py index 4f31a52f3..9544a8e48 100644 --- a/backend/tests/ragas_evaluation/run_evaluation.py +++ b/backend/tests/ragas_evaluation/run_evaluation.py @@ -24,7 +24,7 @@ from modules.knowledge.dto.inputs import CreateKnowledgeProperties from modules.knowledge.service.knowledge_service import KnowledgeService from ragas import evaluate from ragas.embeddings.base import LangchainEmbeddingsWrapper -from repository.files.upload_file import upload_file_storage +from modules.upload.service.upload_file import upload_file_storage def main( diff --git a/backend/llm/utils/call_brain_api.py b/backend/utils/call_brain_api.py similarity index 91% rename from backend/llm/utils/call_brain_api.py rename to backend/utils/call_brain_api.py index 2974118cc..f5b4d51be 100644 --- a/backend/llm/utils/call_brain_api.py +++ b/backend/utils/call_brain_api.py @@ -1,10 +1,10 @@ from uuid import UUID from fastapi import HTTPException -from llm.utils.extract_api_brain_definition_values_from_llm_output import ( +from utils.extract_api_brain_definition_values_from_llm_output import ( extract_api_brain_definition_values_from_llm_output, ) -from llm.utils.make_api_request import get_api_call_response_as_text +from utils.make_api_request import get_api_call_response_as_text from modules.brain.service.api_brain_definition_service import ApiBrainDefinitionService from modules.brain.service.brain_service import BrainService diff --git a/backend/llm/utils/extract_api_brain_definition_values_from_llm_output.py b/backend/utils/extract_api_brain_definition_values_from_llm_output.py similarity index 100% rename from backend/llm/utils/extract_api_brain_definition_values_from_llm_output.py rename to backend/utils/extract_api_brain_definition_values_from_llm_output.py diff --git a/backend/llm/utils/extract_api_definition.py b/backend/utils/extract_api_definition.py similarity index 100% rename from backend/llm/utils/extract_api_definition.py rename to backend/utils/extract_api_definition.py diff --git a/backend/llm/utils/format_chat_history.py b/backend/utils/format_chat_history.py similarity index 100% rename from backend/llm/utils/format_chat_history.py rename to backend/utils/format_chat_history.py diff --git a/backend/llm/utils/get_api_brain_definition_as_json_schema.py b/backend/utils/get_api_brain_definition_as_json_schema.py similarity index 89% rename from backend/llm/utils/get_api_brain_definition_as_json_schema.py rename to backend/utils/get_api_brain_definition_as_json_schema.py index 5f2499ee8..aea38bc93 100644 --- a/backend/llm/utils/get_api_brain_definition_as_json_schema.py +++ b/backend/utils/get_api_brain_definition_as_json_schema.py @@ -1,6 +1,6 @@ from fastapi import HTTPException -from llm.utils.extract_api_definition import format_api_brain_property -from llm.utils.sanitize_function_name import sanitize_function_name +from utils.extract_api_definition import format_api_brain_property +from utils.sanitize_function_name import sanitize_function_name from modules.brain.entity.brain_entity import BrainEntity from modules.brain.service.api_brain_definition_service import ApiBrainDefinitionService diff --git a/backend/llm/utils/get_prompt_to_use.py b/backend/utils/get_prompt_to_use.py similarity index 86% rename from backend/llm/utils/get_prompt_to_use.py rename to backend/utils/get_prompt_to_use.py index f49269210..112fce3cb 100644 --- a/backend/llm/utils/get_prompt_to_use.py +++ b/backend/utils/get_prompt_to_use.py @@ -1,7 +1,7 @@ from typing import Optional from uuid import UUID -from llm.utils.get_prompt_to_use_id import get_prompt_to_use_id +from utils.get_prompt_to_use_id import get_prompt_to_use_id from modules.prompt.service import PromptService promptService = PromptService() diff --git a/backend/llm/utils/get_prompt_to_use_id.py b/backend/utils/get_prompt_to_use_id.py similarity index 100% rename from backend/llm/utils/get_prompt_to_use_id.py rename to backend/utils/get_prompt_to_use_id.py diff --git a/backend/llm/utils/make_api_request.py b/backend/utils/make_api_request.py similarity index 100% rename from backend/llm/utils/make_api_request.py rename to backend/utils/make_api_request.py diff --git a/backend/llm/utils/sanitize_function_name.py b/backend/utils/sanitize_function_name.py similarity index 100% rename from backend/llm/utils/sanitize_function_name.py rename to backend/utils/sanitize_function_name.py