Skip to content

Commit 3258da5

Browse files
increment
1 parent 3cff43a commit 3258da5

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

dspy/adapters/types/base_type.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ def serialize_model(self):
7070
)
7171
return formatted
7272

73+
@classmethod
74+
def is_natively_supported(cls, lm, lm_kwargs) -> bool:
75+
"""Whether the custom type is natively supported by the LM."""
76+
return False
77+
7378
@classmethod
7479
def is_streamable(cls) -> bool:
7580
"""Whether the custom type is streamable."""
@@ -88,7 +93,6 @@ def parse_stream_chunk(cls, chunk: ModelResponseStream) -> Optional["Type"]:
8893
"""
8994
return None
9095

91-
9296
@classmethod
9397
def parse_lm_response(cls, response: str | dict[str, Any]) -> Optional["Type"]:
9498
"""Parse a LM response into the custom type.
@@ -101,6 +105,7 @@ def parse_lm_response(cls, response: str | dict[str, Any]) -> Optional["Type"]:
101105
"""
102106
return None
103107

108+
104109
def split_message_content_for_custom_types(messages: list[dict[str, Any]]) -> list[dict[str, Any]]:
105110
"""Split user message content into a list of content blocks.
106111

dspy/adapters/types/reasoning.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,12 @@ def parse_lm_response(cls, response: str | dict[str, Any]) -> Optional["Reasonin
6161

6262
def __repr__(self) -> str:
6363
return f"{self.content!r}"
64+
65+
def __str__(self) -> str:
66+
return self.content
67+
68+
def __eq__(self, other: object) -> bool:
69+
if isinstance(other, Reasoning):
70+
return self.content == other.content
71+
if isinstance(other, str):
72+
return self.content == other

tests/adapters/test_citation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ class CitationSignature(Signature):
155155
CitationSignature.delete("citations"),
156156
CitationSignature,
157157
outputs,
158-
dspy.LM(model="claude-3-5-sonnet-20241022")
158+
dspy.LM(model="claude-3-5-sonnet-20241022"),
159+
lm_kwargs={},
159160
)
160161

161162
assert len(result) == 1

tests/streaming/test_streaming.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,7 @@ class CustomSignature(dspy.Signature):
907907
)
908908

909909
async def stream(*args, **kwargs):
910+
yield ModelResponseStream(model="gpt-4o-mini", choices=[StreamingChoices(delta=Delta(content="[[ ## answer ## ]]\n"))])
910911
yield ModelResponseStream(model="gpt-4o-mini", choices=[StreamingChoices(delta=Delta(content="Hello"))])
911912
yield ModelResponseStream(model="gpt-4o-mini", choices=[StreamingChoices(delta=Delta(content="World"))])
912913
yield ModelResponseStream(model="gpt-4o-mini", choices=[StreamingChoices(delta=Delta(content="\n\n"))])

0 commit comments

Comments
 (0)