Skip to content

Commit 7c5fc2c

Browse files
committed
bug fix for LLM function calling
Signed-off-by: Mandana Vaziri <[email protected]>
1 parent a61c3af commit 7c5fc2c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/pdl/pdl_llms.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,10 @@ def generate_text(
162162
)
163163
msg = response.choices[0].message # pyright: ignore
164164
if msg.content is None:
165-
assert False, "TODO" # XXX TODO XXX
165+
return {
166+
"role": msg.role,
167+
"content": "",
168+
}, response.json() # pyright: ignore
166169
return {
167170
"role": msg.role,
168171
"content": msg.content,
@@ -190,6 +193,6 @@ def generate_text_stream(
190193
result.append(chunk.json()) # pyright: ignore
191194
msg = chunk.choices[0].delta # pyright: ignore
192195
if msg.content is None:
193-
break
196+
continue
194197
yield {"role": msg.role, "content": msg.content}
195198
return result

tests/results/examples/react/demo.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Act: {"name": "Search", "arguments": {"topic": "Henry Hudson"}}
3535
Obs: Henry Hudson (c. 1565 – disappeared 23 June 1611) was an English sea explorer and navigator during the early 17th century, best known for his explorations of present-day Canada and parts of the Northeastern United States.
3636
In 1607 and 1608, Hudson made two attempts on behalf of English merchants to find a rumoured Northeast Passage to Cathay via a route above the Arctic Circle. In 1609, he landed in North America on behalf of the Dutch East India Company and explored the region around the modern New York metropolitan area. Looking for a Northwest Passage to Asia on his ship Halve Maen ("Half Moon"), he sailed up the Hudson River, which was later named after him, and thereby laid the foundation for Dutch colonization of the region. His contributions to the exploration of the New World were significant and lasting. His voyages helped to establish European contact with the native peoples of North America and contributed to the development of trade and commerce.
3737
On his final expedition, while still searching for the Northwest Passage, Hudson became the first European to see Hudson Strait and the immense Hudson Bay. In 1611, after wintering on the shore of James Bay, Hudson wanted to press on to the west, but most of his crew mutinied. The mutineers cast Hudson, his son, and six others adrift; what then happened to the Hudsons and their companions is unknown.
38+
39+
3840
Tho: Henry Hudson was born around 1565. To find out how many years ago that was, I need to subtract his birth year from the current year, which is 2024.
3941
Act: {"name": "Calc", "arguments": {"expr": "2024 - 1565"}}
4042
Obs: 459

0 commit comments

Comments
 (0)