diff --git a/src/examples/dspy_example/QA_basic.py b/src/examples/dspy_example/QA_basic.py index b146f88c..a2fe556a 100644 --- a/src/examples/dspy_example/QA_basic.py +++ b/src/examples/dspy_example/QA_basic.py @@ -8,8 +8,8 @@ # configure the language model to be used by dspy -llm = dspy.Claude() -dspy.settings.configure(lm=llm) +lm = dspy.LM('claude-3-opus-20240229') +dspy.configure(lm=lm) # create a prompt format that says that the llm will take a question and give back an answer predict = dspy.Predict("question -> answer") diff --git a/src/examples/dspy_example/QA_basic_with_chain_of_thought.py b/src/examples/dspy_example/QA_basic_with_chain_of_thought.py index 3e8f0007..355f9a1f 100644 --- a/src/examples/dspy_example/QA_basic_with_chain_of_thought.py +++ b/src/examples/dspy_example/QA_basic_with_chain_of_thought.py @@ -7,8 +7,8 @@ langtrace.init(disable_instrumentations={"all_except": ["dspy", "anthropic"]}) # configure the language model to be used by dspy -llm = dspy.Claude() -dspy.settings.configure(lm=llm) +lm = dspy.LM('claude-3-opus-20240229') +dspy.configure(lm=lm) # create a signature for basic question answering diff --git a/src/examples/dspy_example/QA_basic_with_signature.py b/src/examples/dspy_example/QA_basic_with_signature.py index ec5ecc28..96be5a20 100644 --- a/src/examples/dspy_example/QA_basic_with_signature.py +++ b/src/examples/dspy_example/QA_basic_with_signature.py @@ -7,8 +7,8 @@ langtrace.init(disable_instrumentations={"all_except": ["dspy", "anthropic"]}) # configure the language model to be used by dspy -llm = dspy.Claude() -dspy.settings.configure(lm=llm) +lm = dspy.LM('claude-3-opus-20240229') +dspy.configure(lm=lm) # create a signature for basic question answering diff --git a/src/examples/dspy_example/QA_multi_step_with_chain_of_thought.py b/src/examples/dspy_example/QA_multi_step_with_chain_of_thought.py index 8c6817a0..1351d443 100644 --- a/src/examples/dspy_example/QA_multi_step_with_chain_of_thought.py +++ b/src/examples/dspy_example/QA_multi_step_with_chain_of_thought.py @@ -7,8 +7,8 @@ langtrace.init(disable_instrumentations={"all_except": ["dspy", "anthropic"]}) # configure the language model to be used by dspy -llm = dspy.Claude() -dspy.settings.configure(lm=llm) +lm = dspy.LM('claude-3-opus-20240229') +dspy.configure(lm=lm) # create a signature for basic question answering diff --git a/src/examples/dspy_example/math_problems_cot.py b/src/examples/dspy_example/math_problems_cot.py index 48c8083b..3badaa00 100644 --- a/src/examples/dspy_example/math_problems_cot.py +++ b/src/examples/dspy_example/math_problems_cot.py @@ -7,8 +7,8 @@ langtrace.init() -turbo = dspy.OpenAI(model="gpt-3.5-turbo", max_tokens=250) -dspy.settings.configure(lm=turbo) +lm = dspy.LM('gpt-3.5-turbo') +dspy.configure(lm=lm) # Load math questions from the GSM8K dataset gsm8k = GSM8K() diff --git a/src/examples/dspy_example/math_problems_cot_parallel.py b/src/examples/dspy_example/math_problems_cot_parallel.py index 690683e8..c04b917a 100644 --- a/src/examples/dspy_example/math_problems_cot_parallel.py +++ b/src/examples/dspy_example/math_problems_cot_parallel.py @@ -9,8 +9,8 @@ langtrace.init() -turbo = dspy.OpenAI(model="gpt-3.5-turbo", max_tokens=250) -dspy.settings.configure(lm=turbo) +lm = dspy.LM('gpt-3.5-turbo') +dspy.configure(lm=lm) # Load math questions from the GSM8K dataset gsm8k = GSM8K() diff --git a/src/examples/dspy_example/program_of_thought_basic.py b/src/examples/dspy_example/program_of_thought_basic.py index a81f8851..153af851 100644 --- a/src/examples/dspy_example/program_of_thought_basic.py +++ b/src/examples/dspy_example/program_of_thought_basic.py @@ -5,8 +5,8 @@ langtrace.init() -turbo = dspy.OpenAI(model="gpt-3.5-turbo", max_tokens=250) -dspy.settings.configure(lm=turbo) +lm = dspy.LM('gpt-3.5-turbo') +dspy.configure(lm=lm) # Define a simple signature for basic question answering diff --git a/src/examples/dspy_example/react.py b/src/examples/dspy_example/react.py index 30c24692..5b9e2ae4 100644 --- a/src/examples/dspy_example/react.py +++ b/src/examples/dspy_example/react.py @@ -15,8 +15,8 @@ langtrace.init() -turbo = dspy.OpenAI(model="gpt-3.5-turbo", max_tokens=250) -dspy.settings.configure(lm=turbo) +lm = dspy.LM('gpt-3.5-turbo') +dspy.configure(lm=lm) colbertv2_wiki17_abstracts = dspy.ColBERTv2( url="http://20.102.90.50:2017/wiki17_abstracts" diff --git a/src/langtrace_python_sdk/instrumentation/cleanlab/patch.py b/src/langtrace_python_sdk/instrumentation/cleanlab/patch.py index abb8cf5f..8a2732bf 100644 --- a/src/langtrace_python_sdk/instrumentation/cleanlab/patch.py +++ b/src/langtrace_python_sdk/instrumentation/cleanlab/patch.py @@ -63,6 +63,10 @@ def traced_method( result_json = str(result) span.set_attribute("tlm.result", str(result_json)) + trustworthiness_score = result_json["trustworthiness_score"] + log = result_json["log"] + span.set_attribute("tlm.trustworthiness_score", str(trustworthiness_score)) + span.set_attribute("tlm.explanation", str(log.get("explanation", ""))) span.set_status(Status(StatusCode.OK)) return result diff --git a/src/langtrace_python_sdk/instrumentation/dspy/instrumentation.py b/src/langtrace_python_sdk/instrumentation/dspy/instrumentation.py index 2433ed42..54d09671 100644 --- a/src/langtrace_python_sdk/instrumentation/dspy/instrumentation.py +++ b/src/langtrace_python_sdk/instrumentation/dspy/instrumentation.py @@ -70,11 +70,6 @@ def _instrument(self, **kwargs): "MultiChainComparison.forward", patch_signature("MultiChainComparison.forward", version, tracer), ) - _W( - "dspy.predict.retry", - "Retry.forward", - patch_signature("Retry.forward", version, tracer), - ) _W( "dspy.evaluate.evaluate", "Evaluate.__call__", diff --git a/src/langtrace_python_sdk/instrumentation/dspy/patch.py b/src/langtrace_python_sdk/instrumentation/dspy/patch.py index 4f181009..bbe1bc2d 100644 --- a/src/langtrace_python_sdk/instrumentation/dspy/patch.py +++ b/src/langtrace_python_sdk/instrumentation/dspy/patch.py @@ -38,7 +38,7 @@ def traced_method(wrapped, instance, args, kwargs): prog = { "name": args[0].prog.__class__.__name__, "signature": ( - str(args[0].prog.signature) if args[0].prog.signature else None + str(args[0].prog.signature) if hasattr(args[0].prog, "signature") else None ), } span_attributes["dspy.optimizer.module.prog"] = json.dumps(prog) diff --git a/src/langtrace_python_sdk/version.py b/src/langtrace_python_sdk/version.py index b40a80d9..b8654104 100644 --- a/src/langtrace_python_sdk/version.py +++ b/src/langtrace_python_sdk/version.py @@ -1 +1 @@ -__version__ = "3.8.14" +__version__ = "3.8.15"