DSPy: The framework for programming—not prompting—language models
Python
Copy lm in execute_finetune_job
dilara1298880d4b5d
diff --git a/dspy/clients/lm.py b/dspy/clients/lm.pyindex 7e42c5865..2c35cadd8 100644--- a/dspy/clients/lm.py+++ b/dspy/clients/lm.py@@ -2,13 +2,12 @@ from concurrent.futures import ThreadPoolExecutorimport functoolsimport osfrom pathlib import Path-import refrom typing import Any, Dict, List, Optional, Type, Unionimport ujsonfrom dspy import logger-from dspy.clients.finetune import FinetuneJob, TrainingMethod+from dspy.clients.finetune import FinetuneJobfrom dspy.clients.self_hosted import (is_self_hosted_model,self_hosted_model_launch,@@ -311,13 +310,11 @@ def execute_finetune_job(else:model = finetune(job=job, **job_kwargs)lm = lm.copy(model=model)+ job.set_result(lm)except Exception as err:logger.error(err)job.set_result(err)- # Set the result to the launched lm- job.set_result(lm)-# TODO: Perhaps we shouldn't directly cache the data# TODO: Add DiskCache, ignore job@@ -345,18 +342,18 @@ def finetune(# Get the fine-tuning providertry:provider = _get_supported_finetune_provider(model)- except Exception as err:- raise err- # Get the finetune function- provider_finetune_function = get_provider_finetune_function(provider)+ # Get the finetune function+ provider_finetune_function = get_provider_finetune_function(provider)- # Fine-tune a new model based on the given model- model = provider_finetune_function(- job=job,- model=model,- message_completion_pairs=message_completion_pairs,- train_kwargs=train_kwargs,- )+ # Fine-tune a new model based on the given model+ model = provider_finetune_function(+ job=job,+ model=model,+ message_completion_pairs=message_completion_pairs,+ train_kwargs=train_kwargs,+ )+ except Exception as err:+ raise errreturn modeldiff --git a/dspy/clients/self_hosted.py b/dspy/clients/self_hosted.pyindex 90c850e7e..e3ca93077 100644--- a/dspy/clients/self_hosted.py+++ b/dspy/clients/self_hosted.py@@ -1,7 +1,5 @@from typing import Dict, Any-from dspy import LM-from dspy import loggerfrom dspy.clients.openai import is_openai_model