- Move to Mistral iso OpenAI as primary choice

This commit is contained in:
Josako
2025-03-06 14:19:35 +01:00
parent 55a89c11bb
commit c15cabc289
11 changed files with 74 additions and 36 deletions

View File

@@ -3,7 +3,7 @@ from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnablePassthrough
from common.extensions import db, minio_client
from common.utils.model_utils import create_language_template
from common.utils.model_utils import create_language_template, get_embedding_llm
from .base_processor import BaseProcessor
from common.utils.business_event_context import current_event
from .processor_registry import ProcessorRegistry
@@ -81,7 +81,7 @@ class HTMLProcessor(BaseProcessor):
def _generate_markdown_from_html(self, html_content):
self._log(f'Generating markdown from HTML for tenant {self.tenant.id}')
llm = self.model_variables.get_llm()
llm = get_embedding_llm()
template = self.model_variables.get_template("html_parse")
parse_prompt = ChatPromptTemplate.from_template(template)
setup = RunnablePassthrough()

View File

@@ -8,7 +8,7 @@ import re
from langchain_core.runnables import RunnablePassthrough
from common.extensions import minio_client
from common.utils.model_utils import create_language_template
from common.utils.model_utils import create_language_template, get_embedding_llm
from .base_processor import BaseProcessor
from common.utils.business_event_context import current_event
from .processor_registry import ProcessorRegistry
@@ -210,7 +210,7 @@ class PDFProcessor(BaseProcessor):
return text_splitter.split_text(content)
def _process_chunks_with_llm(self, chunks):
llm = self.model_variables.get_llm()
llm = get_embedding_llm()
template = self.model_variables.get_template('pdf_parse')
pdf_prompt = ChatPromptTemplate.from_template(template)
setup = RunnablePassthrough()

View File

@@ -4,7 +4,7 @@ from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnablePassthrough
from common.utils.model_utils import create_language_template
from common.utils.model_utils import create_language_template, get_embedding_llm
from .base_processor import BaseProcessor
from common.utils.business_event_context import current_event
@@ -46,7 +46,7 @@ class TranscriptionBaseProcessor(BaseProcessor):
def _process_chunks(self, chunks):
self.log_tuning("_process_chunks", {"Nr of Chunks": len(chunks)})
llm = self.model_variables.get_llm()
llm = get_embedding_llm()
template = self.model_variables.get_template('transcript')
language_template = create_language_template(template, self.document_version.language)
transcript_prompt = ChatPromptTemplate.from_template(language_template)

View File

@@ -17,7 +17,8 @@ from common.models.document import DocumentVersion, Embedding, Document, Process
from common.models.user import Tenant
from common.utils.celery_utils import current_celery
from common.utils.database import Database
from common.utils.model_utils import create_language_template, get_model_variables, get_embedding_model_and_class
from common.utils.model_utils import create_language_template, get_model_variables, get_embedding_model_and_class, \
get_embedding_llm
from common.utils.business_event import BusinessEvent
from common.utils.business_event_context import current_event
@@ -209,7 +210,7 @@ def enrich_chunks(tenant, model_variables, document_version, title, chunks):
def summarize_chunk(tenant, model_variables, document_version, chunk):
current_event.log("Starting Summarizing Chunk")
llm = model_variables.get_llm()
llm = get_embedding_llm()
template = model_variables.get_template("summary")
language_template = create_language_template(template, document_version.language)
summary_prompt = ChatPromptTemplate.from_template(language_template)