mirror of
https://github.com/aljazceru/mcp-python-sdk.git
synced 2025-12-19 23:04:25 +01:00
replace inefficient use of to_jsonable_python (#545)
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
"""Base classes for FastMCP prompts."""
|
||||
|
||||
import inspect
|
||||
import json
|
||||
from collections.abc import Awaitable, Callable, Sequence
|
||||
from typing import Any, Literal
|
||||
|
||||
@@ -155,7 +154,9 @@ class Prompt(BaseModel):
|
||||
content = TextContent(type="text", text=msg)
|
||||
messages.append(UserMessage(content=content))
|
||||
else:
|
||||
content = json.dumps(pydantic_core.to_jsonable_python(msg))
|
||||
content = pydantic_core.to_json(
|
||||
msg, fallback=str, indent=2
|
||||
).decode()
|
||||
messages.append(Message(role="user", content=content))
|
||||
except Exception:
|
||||
raise ValueError(
|
||||
|
||||
Reference in New Issue
Block a user