Implement SEP-1577 - Sampling With Tools (#1594)
Co-authored-by: Felix Weinberger <fweinberger@anthropic.com> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
parent
c51936f61f
commit
71c475588f
2 changed files with 674 additions and 19 deletions
|
|
@ -134,8 +134,8 @@ async def test_sampling(prompt: str, ctx: Context[ServerSession, None]) -> str:
|
|||
max_tokens=100,
|
||||
)
|
||||
|
||||
if result.content.type == "text":
|
||||
model_response = result.content.text
|
||||
if any(c.type == "text" for c in result.content_as_list):
|
||||
model_response = "\n".join(c.text for c in result.content_as_list if c.type == "text")
|
||||
else:
|
||||
model_response = "No response"
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,6 @@ async def generate_poem(topic: str, ctx: Context[ServerSession, None]) -> str:
|
|||
max_tokens=100,
|
||||
)
|
||||
|
||||
if result.content.type == "text":
|
||||
return result.content.text
|
||||
if all(c.type == "text" for c in result.content_as_list):
|
||||
return "\n".join(c.text for c in result.content_as_list if c.type == "text")
|
||||
return str(result.content)
|
||||
|
|
|
|||
Loading…
Reference in a new issue