Skip to content

Commit 00eb07a

Browse files
committed
Refactor: Separate freeform functionality from legacy SFT/Custom_Workflow
- Split synthesis_service.py into: * synthesis_service.py (freeform only) * synthesis_legacy_service.py (SFT & Custom_Workflow) - Split evaluator_service.py into: * evaluator_service.py (freeform only) * evaluator_legacy_service.py (SFT & Custom_Workflow) - Updated main.py to route requests to appropriate services - Updated all dependent files (synthesis_job, model_alignment, run scripts) - Created comprehensive test coverage for both legacy and freeform services - Added .gitignore patterns to prevent committing generated data files - Maintained full backward compatibility - all endpoints work as before This refactoring isolates freeform functionality while preserving existing SFT and Custom_Workflow features without breaking changes.
1 parent 2599758 commit 00eb07a

20 files changed

+1661
-979
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ qa_pairs*
5555
Khauneesh/
5656
*job_args*
5757

58+
# Generated data files
59+
freeform_data_*.json
60+
row_data_*.json
61+
lending_*.json
62+
seeds_*.json
63+
SeedsInstructions.json
64+
*_example.json
65+
nm.json
66+
french_input.json
67+
5868
# DB
5969
*metadata.db-shm
6070
*metadata.db-wal

app/main.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@
4242
sys.path.append(str(ROOT_DIR))
4343

4444
from app.services.evaluator_service import EvaluatorService
45+
from app.services.evaluator_legacy_service import EvaluatorLegacyService
4546
from app.models.request_models import SynthesisRequest, EvaluationRequest, Export_synth, ModelParameters, CustomPromptRequest, JsonDataSize, RelativePath, Technique
4647
from app.services.synthesis_service import SynthesisService
48+
from app.services.synthesis_legacy_service import SynthesisLegacyService
4749
from app.services.export_results import Export_Service
4850

4951
from app.core.prompt_templates import PromptBuilder, PromptHandler
@@ -66,8 +68,10 @@
6668
#****************************************Initialize************************************************
6769

6870
# Initialize services
69-
synthesis_service = SynthesisService()
70-
evaluator_service = EvaluatorService()
71+
synthesis_service = SynthesisService() # Freeform only
72+
synthesis_legacy_service = SynthesisLegacyService() # SFT and Custom_Workflow
73+
evaluator_service = EvaluatorService() # Freeform only
74+
evaluator_legacy_service = EvaluatorLegacyService() # SFT and Custom_Workflow
7175
export_service = Export_Service()
7276
db_manager = DatabaseManager()
7377

@@ -552,9 +556,11 @@ async def generate_examples(request: SynthesisRequest):
552556

553557
if is_demo== True:
554558
if request.input_path:
555-
return await synthesis_service.generate_result(request,is_demo, request_id=request_id)
559+
# Custom_Workflow technique - route to legacy service
560+
return await synthesis_legacy_service.generate_result(request,is_demo, request_id=request_id)
556561
else:
557-
return await synthesis_service.generate_examples(request,is_demo, request_id=request_id)
562+
# SFT technique - route to legacy service
563+
return await synthesis_legacy_service.generate_examples(request,is_demo, request_id=request_id)
558564
else:
559565
return synthesis_job.generate_job(request, core, mem, request_id=request_id)
560566

@@ -626,7 +632,8 @@ async def evaluate_examples(request: EvaluationRequest):
626632

627633
is_demo = request.is_demo
628634
if is_demo:
629-
return evaluator_service.evaluate_results(request, request_id=request_id)
635+
# SFT and Custom_Workflow evaluation - route to legacy service
636+
return evaluator_legacy_service.evaluate_results(request, request_id=request_id)
630637

631638
else:
632639
return synthesis_job.evaluate_job(request, request_id=request_id)
@@ -1242,7 +1249,7 @@ def is_empty(self):
12421249
async def health_check():
12431250
"""Get API health status"""
12441251
#return {"status": "healthy"}
1245-
return synthesis_service.get_health_check()
1252+
return synthesis_legacy_service.get_health_check()
12461253

12471254
@app.get("/{use_case}/example_payloads")
12481255
async def get_example_payloads(use_case:UseCase):

app/run_eval_job.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from app.models.request_models import EvaluationRequest, ModelParameters
3232

3333
from app.services.evaluator_service import EvaluatorService
34+
from app.services.evaluator_legacy_service import EvaluatorLegacyService
3435
import asyncio
3536
import nest_asyncio
3637

@@ -40,7 +41,7 @@
4041
async def run_eval(request, job_name, request_id):
4142
try:
4243

43-
job = EvaluatorService()
44+
job = EvaluatorLegacyService()
4445
result = job.evaluate_results(request,job_name, is_demo=False, request_id=request_id)
4546
return result
4647
except Exception as e:

app/run_job.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import json
3333
from app.models.request_models import SynthesisRequest
3434
from app.services.synthesis_service import SynthesisService
35+
from app.services.synthesis_legacy_service import SynthesisLegacyService
3536
import asyncio
3637
import nest_asyncio # Add this import
3738

@@ -41,7 +42,7 @@
4142
async def run_synthesis(request, job_name, request_id):
4243
"""Run standard synthesis job for question-answer pairs"""
4344
try:
44-
job = SynthesisService()
45+
job = SynthesisLegacyService()
4546
if request.input_path:
4647
result = await job.generate_result(request, job_name, is_demo=False, request_id=request_id)
4748
else:

0 commit comments

Comments
 (0)