1717 extract_keywords ,
1818 create_labeled_object2 ,
1919 get_data_first_block ,
20- getLLM
20+ get_llm_model_name
2121)
2222from markup_doc .models import ProcessStatus
23+ from markup_doc .labeling_utils import MODEL_NAME_GEMINI , MODEL_NAME_LLAMA
2324from markup_doc .sync_api import sync_journals_from_api
2425from markuplib .function_docx import functionsDocx
2526from model_ai .llama import LlamaService , LlamaInputSettings
2627from reference .config_gemini import create_prompt_reference
2728
2829
30+
2931def clean_labels (text ):
3032 # Eliminar etiquetas tipo [kwd] o [sectitle], incluso si tienen espacios como [/ doctitle ]
3133 text = re .sub (r'\[\s*/?\s*\w+(?:\s+[^\]]+)?\s*\]' , '' , text )
@@ -151,16 +153,16 @@ def get_labels(title, user_id):
151153 continue
152154
153155 if item .get ('type' ) == 'first_block' :
154- first_block = LlamaService (mode = 'prompt' , temperature = 0.1 )
156+ llm_first_block = LlamaService (mode = 'prompt' , temperature = 0.1 )
155157
156- if getLLM () == 'GEMINI' :
157- output = first_block .run (LlamaInputSettings .get_first_metadata (clean_labels (item .get ('text' ))))
158+ if get_llm_model_name () == MODEL_NAME_GEMINI :
159+ output = llm_first_block .run (LlamaInputSettings .get_first_metadata (clean_labels (item .get ('text' ))))
158160 match = re .search (r'\{.*\}' , output , re .DOTALL )
159161 if match :
160162 output = match .group (0 )
161163 output = json .loads (output )
162-
163- if getLLM () == 'LLAMA' :
164+
165+ if get_llm_model_name () == MODEL_NAME_LLAMA :
164166
165167 output_author = get_data_first_block (clean_labels (item .get ('text' )), 'author' , user_id )
166168
@@ -283,7 +285,7 @@ def get_labels(title, user_id):
283285
284286 num_refs = [item ["num_ref" ] for item in obj_reference ]
285287
286- if getLLM () == 'LLAMA' :
288+ if get_llm_model_name () == 'LLAMA' :
287289 for obj_ref in obj_reference :
288290 obj = process_reference (obj_ref ['num_ref' ], obj_ref ['obj' ], user_id )
289291 stream_data_back .append (obj )
@@ -297,7 +299,7 @@ def get_labels(title, user_id):
297299 text_references = "\n " .join ([item ["text" ] for item in chunk ]).replace ('<italic>' , '' ).replace ('</italic>' , '' )
298300 prompt_reference = create_prompt_reference (text_references )
299301
300- result = first_block .run (prompt_reference )
302+ result = llm_first_block .run (prompt_reference )
301303
302304 match = re .search (r'\[.*\]' , result , re .DOTALL )
303305 if match :
0 commit comments