diff --git a/app/src/pages/prompt/promptCodeSnippets.tsx b/app/src/pages/prompt/promptCodeSnippets.tsx index 690a67cca6..21e0128fdc 100644 --- a/app/src/pages/prompt/promptCodeSnippets.tsx +++ b/app/src/pages/prompt/promptCodeSnippets.tsx @@ -1,5 +1,4 @@ import { CodeLanguage } from "@phoenix/components/code"; -import { isObject } from "@phoenix/typeUtils"; import type { PromptCodeExportCard__main$data as PromptVersion } from "./__generated__/PromptCodeExportCard__main.graphql"; @@ -110,16 +109,16 @@ export const promptCodeSnippets: Record< messages = `${fmt}`; args.push(`messages=messages`); } - if (isObject(prompt.tools) && "tools" in prompt.tools) { + if (prompt.tools) { const fmt = jsonFormatter({ - json: prompt.tools.tools, + json: prompt.tools.map((tool) => tool.definition), level: 1, }); args.push(`tools=${fmt}`); } - if (prompt.outputSchema && "output_schema" in prompt.outputSchema) { + if (prompt.outputSchema && "schema" in prompt.outputSchema) { const fmt = jsonFormatter({ - json: prompt.outputSchema.output_schema, + json: prompt.outputSchema.schema, level: 1, }); args.push(`response_format=${fmt}`); @@ -170,17 +169,17 @@ print(completion.choices[0].message) messages = `${fmt}`; args.push(`messages`); } - if (isObject(prompt.tools) && "tools" in prompt.tools) { + if (prompt.tools) { const fmt = jsonFormatter({ - json: prompt.tools.tools, + json: prompt.tools.map((tool) => tool.definition), level: 1, removeKeyQuotes: true, }); args.push(`tools: ${fmt}`); } - if (prompt.outputSchema && "output_schema" in prompt.outputSchema) { + if (prompt.outputSchema && "schema" in prompt.outputSchema) { const fmt = jsonFormatter({ - json: prompt.outputSchema.output_schema, + json: prompt.outputSchema.schema, level: 1, removeKeyQuotes: true, }); diff --git a/src/phoenix/server/api/queries.py b/src/phoenix/server/api/queries.py index a7641e2253..f406739cba 100644 --- a/src/phoenix/server/api/queries.py +++ b/src/phoenix/server/api/queries.py @@ -51,6 +51,7 @@ from phoenix.server.api.types.GenerativeModel import GenerativeModel from phoenix.server.api.types.GenerativeProvider import GenerativeProvider, GenerativeProviderKey from phoenix.server.api.types.InferencesRole import AncillaryInferencesRole, InferencesRole +from phoenix.server.api.types.JSONSchema import JSONSchema from phoenix.server.api.types.Model import Model from phoenix.server.api.types.node import from_global_id, from_global_id_with_expected_type from phoenix.server.api.types.pagination import ConnectionArgs, CursorString, connection_from_list @@ -563,30 +564,32 @@ async def node(self, id: GlobalID, info: Info[Context, None]) -> Node: tools=[ ToolDefinition( definition={ - "name": "get_current_weather", - "description": "Get the current weather in a given location", - "parameters": { - "type": "object", - "properties": { - "location": { - "type": "string", - "description": "A location in the world", - }, - "unit": { - "type": "string", - "enum": ["celsius", "fahrenheit"], - "default": "fahrenheit", - "description": "The unit of temperature", + "type": "function", + "function": { + "name": "get_current_weather", + "description": "Get the current weather in a given location", + "parameters": { + "type": "object", + "properties": { + "location": { + "type": "string", + "description": "A location in the world", + }, + "unit": { + "type": "string", + "enum": ["celsius", "fahrenheit"], + "default": "fahrenheit", + "description": "The unit of temperature", + }, }, + "required": ["location"], }, - "required": ["location"], }, } ) ], - output_schema={ - "_version": "output-schema-v1", - "output_schema": { + output_schema=JSONSchema( + schema={ "type": "json_schema", "json_schema": { "type": "object", @@ -598,7 +601,7 @@ async def node(self, id: GlobalID, info: Info[Context, None]) -> Node: "required": ["temperature", "location", "unit"], }, }, - }, + ), model_name="gpt-4o", model_provider="openai", ) diff --git a/src/phoenix/server/api/types/Prompt.py b/src/phoenix/server/api/types/Prompt.py index a022c4f7fd..634b7d6ab8 100644 --- a/src/phoenix/server/api/types/Prompt.py +++ b/src/phoenix/server/api/types/Prompt.py @@ -62,30 +62,32 @@ async def prompt_versions( tools=[ ToolDefinition( definition={ - "name": "get_current_weather", - "description": "Get the current weather in a given location", - "parameters": { - "type": "object", - "properties": { - "location": { - "type": "string", - "description": "A location in the world", - }, - "unit": { - "type": "string", - "enum": ["celsius", "fahrenheit"], - "default": "fahrenheit", - "description": "The unit of temperature", + "type": "function", + "function": { + "name": "get_current_weather", + "description": "Get the current weather in a given location", + "parameters": { + "type": "object", + "properties": { + "location": { + "type": "string", + "description": "A location in the world", + }, + "unit": { + "type": "string", + "enum": ["celsius", "fahrenheit"], + "default": "fahrenheit", + "description": "The unit of temperature", + }, }, + "required": ["location"], }, - "required": ["location"], }, } ) ], - output_schema={ - "_version": "output-schema-v1", - "output_schema": { + output_schema=JSONSchema( + schema={ "type": "json_schema", "json_schema": { "type": "object", @@ -97,7 +99,7 @@ async def prompt_versions( "required": ["temperature", "location", "unit"], }, }, - }, + ), model_name="gpt-4o", model_provider="openai", ),