Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

Automatic Style fixes

thomasahle5dc385fcce33
diff --git a/dspy/__init__.py b/dspy/__init__.py
index d0abf41b6..d76b3f828 100644
--- a/dspy/__init__.py
+++ b/dspy/__init__.py
@@ -1,11 +1,11 @@
import dsp
from dsp.modules.hf_client import ChatModuleClient, HFClientSGLang, HFClientVLLM, HFServerTGI
+from .functional import *
from .predict import *
from .primitives import *
from .retrieve import *
from .signatures import *
-from .functional import *
settings = dsp.settings
diff --git a/dspy/functional/functional.py b/dspy/functional/functional.py
index aaf0f26ed..292a6bef1 100644
--- a/dspy/functional/functional.py
+++ b/dspy/functional/functional.py
@@ -226,7 +226,7 @@ class TypedPredictor(dspy.Module):
else:
# If there are no errors, we return the parsed results
return Prediction.from_completions(
- {key: [r[key] for r in parsed_results] for key in signature.output_fields}
+ {key: [r[key] for r in parsed_results] for key in signature.output_fields},
)
raise ValueError(
"Too many retries trying to get the correct output format. " + "Try simplifying the requirements.",
@@ -353,8 +353,8 @@ def gold_passages_retrieved(example, pred, _trace=None) -> bool:
def hotpot() -> None:
- from dsp.utils import deduplicate
import dspy.evaluate
+ from dsp.utils import deduplicate
from dspy.datasets import HotPotQA
from dspy.evaluate.evaluate import Evaluate
from dspy.teleprompt.bootstrap import BootstrapFewShot
diff --git a/dspy/primitives/module.py b/dspy/primitives/module.py
index d503345ea..90908e5c3 100644
--- a/dspy/primitives/module.py
+++ b/dspy/primitives/module.py
@@ -1,5 +1,5 @@
import copy
-from typing import Generator
+from collections.abc import Generator
import ujson
diff --git a/dspy/teleprompt/signature_opt_typed.py b/dspy/teleprompt/signature_opt_typed.py
index 956ea0f0c..1921f8cd1 100644
--- a/dspy/teleprompt/signature_opt_typed.py
+++ b/dspy/teleprompt/signature_opt_typed.py
@@ -2,10 +2,11 @@ import textwrap
from typing import Generic, Literal, TypeVar
import pydantic
+
import dspy
+from dspy import BaseModel
from dspy.functional.functional import TypedChainOfThought, TypedPredictor
from dspy.signatures import Signature
-from dspy import BaseModel
from dspy.signatures.field import InputField, OutputField
# TODO:
diff --git a/examples/generation.py b/examples/generation.py
index 36d3d1c92..4ccb2d8fe 100644
--- a/examples/generation.py
+++ b/examples/generation.py
@@ -1,8 +1,9 @@
from pydantic import BaseModel, Field
-from dspy.teleprompt import LabeledFewShot
-from dspy.functional import TypedPredictor
import dspy
+from dspy.functional import TypedPredictor
+from dspy.teleprompt import LabeledFewShot
+
turbo = dspy.OpenAI(model='gpt-3.5-turbo')
colbertv2_wiki17_abstracts = dspy.ColBERTv2(url='http://20.102.90.50:2017/wiki17_abstracts')
dspy.settings.configure(lm=turbo, rm=colbertv2_wiki17_abstracts)