feat: backwards-compatible create_message overloads for SEP-1577 (#1713)

This commit is contained in:
Felix Weinberger 2025-12-02 13:17:45 +00:00 • committed by GitHub
commit fa851d93a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 209 additions and 32 deletions

View file

@ -178,8 +178,9 @@ async def test_sampling(prompt: str, ctx: Context[ServerSession, None]) -> str:
max_tokens=100,
)
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")
# Since we're not passing tools param, result.content is single content
if result.content.type == "text":
model_response = result.content.text
else:
model_response = "No response"

View file

@ -20,6 +20,7 @@ async def generate_poem(topic: str, ctx: Context[ServerSession, None]) -> str:
max_tokens=100,
)
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")
# Since we're not passing tools param, result.content is single content
if result.content.type == "text":
return result.content.text
return str(result.content)