From 4b8c9388dd9c895ca4515897cb4b092e751d51ff Mon Sep 17 00:00:00 2001 From: Xander Song Date: Wed, 29 Jan 2025 15:04:41 -0800 Subject: [PATCH] fix(prompts): remove template type from input for create prompt mutations (#6196) --- app/schema.graphql | 1 - ...romTemplateDialogCreateMutation.graphql.ts | 4 +-- ...romTemplateDialogUpdateMutation.graphql.ts | 4 +-- .../pages/playground/fetchPlaygroundPrompt.ts | 1 - .../api/input_types/PromptVersionInput.py | 2 -- .../server/api/mutations/prompt_mutations.py | 2 ++ tests/integration/auth/test_auth.py | 2 -- .../api/mutations/test_prompt_mutations.py | 26 ------------------- 8 files changed, 4 insertions(+), 38 deletions(-) diff --git a/app/schema.graphql b/app/schema.graphql index 9c3ed34512..3fa17efad6 100644 --- a/app/schema.graphql +++ b/app/schema.graphql @@ -201,7 +201,6 @@ type ChatCompletionToolCall { input ChatPromptVersionInput { description: String = null - templateType: PromptTemplateType! templateFormat: PromptTemplateFormat! template: PromptChatTemplateInput! invocationParameters: JSON! = {} diff --git a/app/src/pages/playground/__generated__/UpsertPromptFromTemplateDialogCreateMutation.graphql.ts b/app/src/pages/playground/__generated__/UpsertPromptFromTemplateDialogCreateMutation.graphql.ts index 2a23d4d680..7cc65228b4 100644 --- a/app/src/pages/playground/__generated__/UpsertPromptFromTemplateDialogCreateMutation.graphql.ts +++ b/app/src/pages/playground/__generated__/UpsertPromptFromTemplateDialogCreateMutation.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<<6625e5bd96ea93dc899253cf49068055>> * @lightSyntaxTransform * @nogrep */ @@ -10,7 +10,6 @@ import { ConcreteRequest, Mutation } from 'relay-runtime'; export type PromptTemplateFormat = "FSTRING" | "MUSTACHE" | "NONE"; -export type PromptTemplateType = "CHAT" | "STRING"; export type CreateChatPromptInput = { description?: string | null; name: string; @@ -24,7 +23,6 @@ export type ChatPromptVersionInput = { outputSchema?: OutputSchemaInput | null; template: PromptChatTemplateInput; templateFormat: PromptTemplateFormat; - templateType: PromptTemplateType; tools?: ReadonlyArray; }; export type PromptChatTemplateInput = { diff --git a/app/src/pages/playground/__generated__/UpsertPromptFromTemplateDialogUpdateMutation.graphql.ts b/app/src/pages/playground/__generated__/UpsertPromptFromTemplateDialogUpdateMutation.graphql.ts index 3bfd834a66..597b31a56d 100644 --- a/app/src/pages/playground/__generated__/UpsertPromptFromTemplateDialogUpdateMutation.graphql.ts +++ b/app/src/pages/playground/__generated__/UpsertPromptFromTemplateDialogUpdateMutation.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<<79cdcb05932a08237487d8ae344fc5a4>> * @lightSyntaxTransform * @nogrep */ @@ -10,7 +10,6 @@ import { ConcreteRequest, Mutation } from 'relay-runtime'; export type PromptTemplateFormat = "FSTRING" | "MUSTACHE" | "NONE"; -export type PromptTemplateType = "CHAT" | "STRING"; export type CreateChatPromptVersionInput = { promptId: string; promptVersion: ChatPromptVersionInput; @@ -24,7 +23,6 @@ export type ChatPromptVersionInput = { outputSchema?: OutputSchemaInput | null; template: PromptChatTemplateInput; templateFormat: PromptTemplateFormat; - templateType: PromptTemplateType; tools?: ReadonlyArray; }; export type PromptChatTemplateInput = { diff --git a/app/src/pages/playground/fetchPlaygroundPrompt.ts b/app/src/pages/playground/fetchPlaygroundPrompt.ts index 53a2f656de..05601bcaf0 100644 --- a/app/src/pages/playground/fetchPlaygroundPrompt.ts +++ b/app/src/pages/playground/fetchPlaygroundPrompt.ts @@ -348,7 +348,6 @@ export const instanceToPromptVersion = (instance: PlaygroundInstance) => { const newPromptVersion = { modelName: instance.model.modelName || DEFAULT_MODEL_NAME, modelProvider: instance.model.provider, - templateType: "CHAT", template: { messages: templateMessages, }, diff --git a/src/phoenix/server/api/input_types/PromptVersionInput.py b/src/phoenix/server/api/input_types/PromptVersionInput.py index 3266d86da2..33b50cd912 100644 --- a/src/phoenix/server/api/input_types/PromptVersionInput.py +++ b/src/phoenix/server/api/input_types/PromptVersionInput.py @@ -6,7 +6,6 @@ from phoenix.server.api.helpers.prompts.models import ( ImageContentValue, PromptTemplateFormat, - PromptTemplateType, PromptToolDefinition, TextContentValue, ToolCallContentValue, @@ -79,7 +78,6 @@ class PromptChatTemplateInput: @strawberry.input class ChatPromptVersionInput: description: Optional[str] = None - template_type: PromptTemplateType template_format: PromptTemplateFormat template: PromptChatTemplateInput invocation_parameters: JSON = strawberry.field(default_factory=dict) diff --git a/src/phoenix/server/api/mutations/prompt_mutations.py b/src/phoenix/server/api/mutations/prompt_mutations.py index a7fabbbfaf..a2c3c17219 100644 --- a/src/phoenix/server/api/mutations/prompt_mutations.py +++ b/src/phoenix/server/api/mutations/prompt_mutations.py @@ -90,6 +90,7 @@ async def create_chat_prompt( **strawberry.asdict(input.prompt_version), "tools": tools, }, + template_type="CHAT", user_id=user_id, ) except ValidationError as error: @@ -144,6 +145,7 @@ async def create_chat_prompt_version( **strawberry.asdict(input.prompt_version), "tools": tools, }, + template_type="CHAT", user_id=user_id, ) except ValidationError as error: diff --git a/tests/integration/auth/test_auth.py b/tests/integration/auth/test_auth.py index b6b1490bc9..017d5313ea 100644 --- a/tests/integration/auth/test_auth.py +++ b/tests/integration/auth/test_auth.py @@ -1012,7 +1012,6 @@ def test_authenticated_users_are_recorded_in_prompts( "description": "prompt-description", "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -1058,7 +1057,6 @@ def test_authenticated_users_are_recorded_in_prompts( "promptId": prompt_id, "promptVersion": { "description": "new-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ diff --git a/tests/unit/server/api/mutations/test_prompt_mutations.py b/tests/unit/server/api/mutations/test_prompt_mutations.py index 2c5047b6c7..2141bad6e1 100644 --- a/tests/unit/server/api/mutations/test_prompt_mutations.py +++ b/tests/unit/server/api/mutations/test_prompt_mutations.py @@ -158,7 +158,6 @@ class TestPromptMutations: "description": "prompt-description", "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -183,7 +182,6 @@ class TestPromptMutations: "description": "prompt-description", "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -209,7 +207,6 @@ class TestPromptMutations: "description": "prompt-description", "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -248,7 +245,6 @@ class TestPromptMutations: "description": "prompt-description", "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -296,7 +292,6 @@ class TestPromptMutations: "description": "prompt-description", "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -377,7 +372,6 @@ async def test_create_chat_prompt_fails_on_name_conflict( "description": "prompt-description", "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -413,7 +407,6 @@ async def test_create_chat_prompt_fails_on_name_conflict( "description": "prompt-description", "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": {"messages": [{"role": "USER", "content": "hello world"}]}, "invocationParameters": {"temperature": 0.4}, @@ -434,7 +427,6 @@ async def test_create_chat_prompt_fails_on_name_conflict( "description": "prompt-description", "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -462,7 +454,6 @@ async def test_create_chat_prompt_fails_on_name_conflict( "description": "prompt-description", "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -492,7 +483,6 @@ async def test_create_chat_prompt_fails_on_name_conflict( "description": "prompt-description", "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -531,7 +521,6 @@ async def test_create_chat_prompt_fails_on_name_conflict( "description": "prompt-description", "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -593,7 +582,6 @@ async def test_create_chat_prompt_fails_with_invalid_input( "promptId": str(GlobalID("Prompt", "1")), "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -617,7 +605,6 @@ async def test_create_chat_prompt_fails_with_invalid_input( "promptId": str(GlobalID("Prompt", "1")), "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -642,7 +629,6 @@ async def test_create_chat_prompt_fails_with_invalid_input( "promptId": str(GlobalID("Prompt", "1")), "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -680,7 +666,6 @@ async def test_create_chat_prompt_fails_with_invalid_input( "promptId": str(GlobalID("Prompt", "1")), "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -707,7 +692,6 @@ async def test_create_chat_prompt_fails_with_invalid_input( "promptId": str(GlobalID("Prompt", "1")), "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -765,7 +749,6 @@ async def test_create_chat_prompt_version_succeeds_with_valid_input( "description": "prompt-description", "promptVersion": { "description": "initial-version", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -837,7 +820,6 @@ async def test_create_chat_prompt_version_fails_with_nonexistent_prompt_id( "promptId": str(GlobalID("Prompt", "100")), "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -864,7 +846,6 @@ async def test_create_chat_prompt_version_fails_with_nonexistent_prompt_id( "promptId": str(GlobalID("Prompt", "1")), "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": {"messages": [{"role": "USER", "content": "hello world"}]}, "invocationParameters": {"temperature": 0.4}, @@ -881,7 +862,6 @@ async def test_create_chat_prompt_version_fails_with_nonexistent_prompt_id( "promptId": str(GlobalID("Prompt", "1")), "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -908,7 +888,6 @@ async def test_create_chat_prompt_version_fails_with_nonexistent_prompt_id( "promptId": str(GlobalID("Prompt", "1")), "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -935,7 +914,6 @@ async def test_create_chat_prompt_version_fails_with_nonexistent_prompt_id( "promptId": str(GlobalID("Prompt", "1")), "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -973,7 +951,6 @@ async def test_create_chat_prompt_version_fails_with_nonexistent_prompt_id( "promptId": str(GlobalID("Prompt", "1")), "promptVersion": { "description": "prompt-version-description", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -1034,7 +1011,6 @@ async def test_create_chat_prompt_version_fails_with_invalid_input( "description": "prompt-description", "promptVersion": { "description": "initial-version", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -1075,7 +1051,6 @@ async def test_create_chat_prompt_version_fails_with_invalid_input( "description": "prompt-description", "promptVersion": { "description": "initial-version", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [ @@ -1164,7 +1139,6 @@ async def test_clone_prompt_succeeds_with_valid_input( "description": "prompt-description", "promptVersion": { "description": "initial-version", - "templateType": "CHAT", "templateFormat": "MUSTACHE", "template": { "messages": [