Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/prompt-foundry%2Fprompt-foundry-sdk-6c87a6d2f0a1447fab78657f8b44e2d1ea2c282d2c9f92458bcd25f543944c6e.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/prompt-foundry%2Fprompt-foundry-sdk-9cff8ea13f14bd0899df69243fe78b4f88d4d0172263aa260af1ea66a7d0484e.yml
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ response = client.completion.with_raw_response.create(
print(response.headers.get('X-My-Header'))

completion = response.parse() # get the object that `completion.create()` would have returned
print(completion.provider)
print(completion.message)
```

These methods return an [`APIResponse`](https://github.com/prompt-foundry/python-sdk/tree/main/src/prompt_foundry_python_sdk/_response.py) object.
Expand Down
4 changes: 2 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Types:

```python
from prompt_foundry_python_sdk.types import (
ModelParameters,
Parameters,
PromptConfiguration,
PromptListResponse,
PromptDeleteResponse,
Expand All @@ -30,7 +30,7 @@ Methods:
- <code title="get /sdk/v1/prompts">client.prompts.<a href="./src/prompt_foundry_python_sdk/resources/prompts.py">list</a>() -> <a href="./src/prompt_foundry_python_sdk/types/prompt_list_response.py">PromptListResponse</a></code>
- <code title="delete /sdk/v1/prompts/{id}">client.prompts.<a href="./src/prompt_foundry_python_sdk/resources/prompts.py">delete</a>(id) -> <a href="./src/prompt_foundry_python_sdk/types/prompt_delete_response.py">PromptDeleteResponse</a></code>
- <code title="get /sdk/v1/prompts/{id}">client.prompts.<a href="./src/prompt_foundry_python_sdk/resources/prompts.py">get</a>(id) -> <a href="./src/prompt_foundry_python_sdk/types/prompt_configuration.py">PromptConfiguration</a></code>
- <code title="post /sdk/v1/prompts/{id}">client.prompts.<a href="./src/prompt_foundry_python_sdk/resources/prompts.py">get_parameters</a>(id, \*\*<a href="src/prompt_foundry_python_sdk/types/prompt_get_parameters_params.py">params</a>) -> <a href="./src/prompt_foundry_python_sdk/types/model_parameters.py">ModelParameters</a></code>
- <code title="post /sdk/v1/prompts/{id}">client.prompts.<a href="./src/prompt_foundry_python_sdk/resources/prompts.py">get_parameters</a>(id, \*\*<a href="src/prompt_foundry_python_sdk/types/prompt_get_parameters_params.py">params</a>) -> <a href="./src/prompt_foundry_python_sdk/types/parameters.py">Parameters</a></code>

# Tools

Expand Down
28 changes: 13 additions & 15 deletions src/prompt_foundry_python_sdk/resources/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
async_to_streamed_response_wrapper,
)
from .._base_client import make_request_options
from ..types.model_parameters import ModelParameters
from ..types.parameters import Parameters
from ..types.prompt_configuration import PromptConfiguration
from ..types.prompt_list_response import PromptListResponse
from ..types.prompt_delete_response import PromptDeleteResponse
Expand Down Expand Up @@ -228,12 +228,11 @@ def get_parameters(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> ModelParameters:
) -> Parameters:
"""
Fetches the configured model parameters and messages rendered with the provided
variables mapped to the set LLM provider. This endpoint abstracts the need to
handle mapping between different providers, while still allowing direct calls to
the providers.
Fetches the model configuration parameters for a specified prompt, including
penalty settings, response format, and the model messages rendered with the
given variables mapped to the set LLM provider.

Args:
append_messages: Appended the the end of the configured prompt messages before running the
Expand All @@ -257,7 +256,7 @@ def get_parameters(
if not id:
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
return cast(
ModelParameters,
Parameters,
self._post(
f"/sdk/v1/prompts/{id}",
body=maybe_transform(
Expand All @@ -272,7 +271,7 @@ def get_parameters(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=cast(Any, ModelParameters), # Union types cannot be passed in as arguments in the type system
cast_to=cast(Any, Parameters), # Union types cannot be passed in as arguments in the type system
),
)

Expand Down Expand Up @@ -476,12 +475,11 @@ async def get_parameters(
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> ModelParameters:
) -> Parameters:
"""
Fetches the configured model parameters and messages rendered with the provided
variables mapped to the set LLM provider. This endpoint abstracts the need to
handle mapping between different providers, while still allowing direct calls to
the providers.
Fetches the model configuration parameters for a specified prompt, including
penalty settings, response format, and the model messages rendered with the
given variables mapped to the set LLM provider.

Args:
append_messages: Appended the the end of the configured prompt messages before running the
Expand All @@ -505,7 +503,7 @@ async def get_parameters(
if not id:
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
return cast(
ModelParameters,
Parameters,
await self._post(
f"/sdk/v1/prompts/{id}",
body=await async_maybe_transform(
Expand All @@ -520,7 +518,7 @@ async def get_parameters(
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=cast(Any, ModelParameters), # Union types cannot be passed in as arguments in the type system
cast_to=cast(Any, Parameters), # Union types cannot be passed in as arguments in the type system
),
)

Expand Down
2 changes: 1 addition & 1 deletion src/prompt_foundry_python_sdk/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from .tool import Tool as Tool
from .evaluation import Evaluation as Evaluation
from .model_parameters import ModelParameters as ModelParameters
from .parameters import Parameters as Parameters
from .tool_create_params import ToolCreateParams as ToolCreateParams
from .tool_list_response import ToolListResponse as ToolListResponse
from .tool_update_params import ToolUpdateParams as ToolUpdateParams
Expand Down
12 changes: 6 additions & 6 deletions src/prompt_foundry_python_sdk/types/completion_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
"CompletionCreateParams",
"AppendMessage",
"AppendMessageContent",
"AppendMessageContentTextContentBlock",
"AppendMessageContentTextContentBlockSchema",
"AppendMessageContentImageBase64ContentBlock",
"AppendMessageContentToolCallContentBlock",
"AppendMessageContentToolCallContentBlockToolCall",
"AppendMessageContentToolCallContentBlockToolCallFunction",
"AppendMessageContentToolResultContentBlock",
"OverrideMessage",
"OverrideMessageContent",
"OverrideMessageContentTextContentBlock",
"OverrideMessageContentTextContentBlockSchema",
"OverrideMessageContentImageBase64ContentBlock",
"OverrideMessageContentToolCallContentBlock",
"OverrideMessageContentToolCallContentBlockToolCall",
Expand Down Expand Up @@ -48,7 +48,7 @@ class CompletionCreateParams(TypedDict, total=False):
"""The template variables added to the prompt when executing the prompt."""


class AppendMessageContentTextContentBlock(TypedDict, total=False):
class AppendMessageContentTextContentBlockSchema(TypedDict, total=False):
text: Required[str]

type: Required[Literal["TEXT"]]
Expand Down Expand Up @@ -100,7 +100,7 @@ class AppendMessageContentToolResultContentBlock(TypedDict, total=False):


AppendMessageContent: TypeAlias = Union[
AppendMessageContentTextContentBlock,
AppendMessageContentTextContentBlockSchema,
AppendMessageContentImageBase64ContentBlock,
AppendMessageContentToolCallContentBlock,
AppendMessageContentToolResultContentBlock,
Expand All @@ -113,7 +113,7 @@ class AppendMessage(TypedDict, total=False):
role: Required[Literal["assistant", "system", "tool", "user"]]


class OverrideMessageContentTextContentBlock(TypedDict, total=False):
class OverrideMessageContentTextContentBlockSchema(TypedDict, total=False):
text: Required[str]

type: Required[Literal["TEXT"]]
Expand Down Expand Up @@ -165,7 +165,7 @@ class OverrideMessageContentToolResultContentBlock(TypedDict, total=False):


OverrideMessageContent: TypeAlias = Union[
OverrideMessageContentTextContentBlock,
OverrideMessageContentTextContentBlockSchema,
OverrideMessageContentImageBase64ContentBlock,
OverrideMessageContentToolCallContentBlock,
OverrideMessageContentToolResultContentBlock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"CompletionCreateResponse",
"Message",
"MessageContent",
"MessageContentTextContentBlock",
"MessageContentTextContentBlockSchema",
"MessageContentImageBase64ContentBlock",
"MessageContentToolCallContentBlock",
"MessageContentToolCallContentBlockToolCall",
Expand All @@ -22,7 +22,7 @@
]


class MessageContentTextContentBlock(BaseModel):
class MessageContentTextContentBlockSchema(BaseModel):
text: str

type: Literal["TEXT"]
Expand Down Expand Up @@ -75,7 +75,7 @@ class MessageContentToolResultContentBlock(BaseModel):

MessageContent: TypeAlias = Annotated[
Union[
MessageContentTextContentBlock,
MessageContentTextContentBlockSchema,
MessageContentImageBase64ContentBlock,
MessageContentToolCallContentBlock,
MessageContentToolResultContentBlock,
Expand Down Expand Up @@ -108,9 +108,4 @@ class CompletionCreateResponse(BaseModel):
message: Message
"""The completion message generated by the model."""

name: str

provider: Literal["ANTHROPIC", "OPENAI"]
"""The LLM model provider."""

stats: Stats
6 changes: 3 additions & 3 deletions src/prompt_foundry_python_sdk/types/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"Evaluation",
"AppendedMessage",
"AppendedMessageContent",
"AppendedMessageContentTextContentBlock",
"AppendedMessageContentTextContentBlockSchema",
"AppendedMessageContentImageBase64ContentBlock",
"AppendedMessageContentToolCallContentBlock",
"AppendedMessageContentToolCallContentBlockToolCall",
Expand All @@ -21,7 +21,7 @@
]


class AppendedMessageContentTextContentBlock(BaseModel):
class AppendedMessageContentTextContentBlockSchema(BaseModel):
text: str

type: Literal["TEXT"]
Expand Down Expand Up @@ -74,7 +74,7 @@ class AppendedMessageContentToolResultContentBlock(BaseModel):

AppendedMessageContent: TypeAlias = Annotated[
Union[
AppendedMessageContentTextContentBlock,
AppendedMessageContentTextContentBlockSchema,
AppendedMessageContentImageBase64ContentBlock,
AppendedMessageContentToolCallContentBlock,
AppendedMessageContentToolResultContentBlock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"EvaluationCreateParams",
"AppendedMessage",
"AppendedMessageContent",
"AppendedMessageContentTextContentBlock",
"AppendedMessageContentTextContentBlockSchema",
"AppendedMessageContentImageBase64ContentBlock",
"AppendedMessageContentToolCallContentBlock",
"AppendedMessageContentToolCallContentBlockToolCall",
Expand All @@ -36,7 +36,7 @@ class EvaluationCreateParams(TypedDict, total=False):
"""How heavily to weigh the evaluation within the prompt."""


class AppendedMessageContentTextContentBlock(TypedDict, total=False):
class AppendedMessageContentTextContentBlockSchema(TypedDict, total=False):
text: Required[str]

type: Required[Literal["TEXT"]]
Expand Down Expand Up @@ -88,7 +88,7 @@ class AppendedMessageContentToolResultContentBlock(TypedDict, total=False):


AppendedMessageContent: TypeAlias = Union[
AppendedMessageContentTextContentBlock,
AppendedMessageContentTextContentBlockSchema,
AppendedMessageContentImageBase64ContentBlock,
AppendedMessageContentToolCallContentBlock,
AppendedMessageContentToolResultContentBlock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"EvaluationUpdateParams",
"AppendedMessage",
"AppendedMessageContent",
"AppendedMessageContentTextContentBlock",
"AppendedMessageContentTextContentBlockSchema",
"AppendedMessageContentImageBase64ContentBlock",
"AppendedMessageContentToolCallContentBlock",
"AppendedMessageContentToolCallContentBlockToolCall",
Expand All @@ -36,7 +36,7 @@ class EvaluationUpdateParams(TypedDict, total=False):
"""How heavily to weigh the evaluation within the prompt."""


class AppendedMessageContentTextContentBlock(TypedDict, total=False):
class AppendedMessageContentTextContentBlockSchema(TypedDict, total=False):
text: Required[str]

type: Required[Literal["TEXT"]]
Expand Down Expand Up @@ -88,7 +88,7 @@ class AppendedMessageContentToolResultContentBlock(TypedDict, total=False):


AppendedMessageContent: TypeAlias = Union[
AppendedMessageContentTextContentBlock,
AppendedMessageContentTextContentBlockSchema,
AppendedMessageContentImageBase64ContentBlock,
AppendedMessageContentToolCallContentBlock,
AppendedMessageContentToolResultContentBlock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .._models import BaseModel

__all__ = [
"ModelParameters",
"Parameters",
"AnthropicModelParameters",
"AnthropicModelParametersParameters",
"AnthropicModelParametersParametersMessage",
Expand Down Expand Up @@ -425,4 +425,4 @@ class OpenAIModelParameters(BaseModel):
provider: Literal["openai"]


ModelParameters: TypeAlias = Union[AnthropicModelParameters, OpenAIModelParameters]
Parameters: TypeAlias = Union[AnthropicModelParameters, OpenAIModelParameters]
16 changes: 8 additions & 8 deletions src/prompt_foundry_python_sdk/types/prompt_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"PromptConfiguration",
"Message",
"MessageContent",
"MessageContentTextContentBlock",
"MessageContentTextContentBlockSchema",
"MessageContentImageBase64ContentBlock",
"MessageContentToolCallContentBlock",
"MessageContentToolCallContentBlockToolCall",
Expand All @@ -23,7 +23,7 @@
]


class MessageContentTextContentBlock(BaseModel):
class MessageContentTextContentBlockSchema(BaseModel):
text: str

type: Literal["TEXT"]
Expand Down Expand Up @@ -76,7 +76,7 @@ class MessageContentToolResultContentBlock(BaseModel):

MessageContent: TypeAlias = Annotated[
Union[
MessageContentTextContentBlock,
MessageContentTextContentBlockSchema,
MessageContentImageBase64ContentBlock,
MessageContentToolCallContentBlock,
MessageContentToolResultContentBlock,
Expand All @@ -98,17 +98,17 @@ class Parameters(BaseModel):
max_tokens: Optional[float] = FieldInfo(alias="maxTokens", default=None)
"""Example: 100"""

name: str
"""The name of the model for the provider."""
api_model_name: str = FieldInfo(alias="modelName")
"""Example: "gpt-3.5-turbo" """

api_model_provider: Literal["ANTHROPIC", "OPENAI"] = FieldInfo(alias="modelProvider")
"""The provider of the provided model."""

parallel_tool_calls: bool = FieldInfo(alias="parallelToolCalls")

presence_penalty: float = FieldInfo(alias="presencePenalty")
"""Example: 0"""

provider: Literal["ANTHROPIC", "OPENAI"]
"""The LLM model provider."""

response_format: Literal["JSON", "TEXT"] = FieldInfo(alias="responseFormat")
"""Example: PromptResponseFormat.TEXT"""

Expand Down
Loading