Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions scripts/api_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
"/e2e_fetch_trace/",
"/e2e_fetch_span_score/",
"/e2e_fetch_trace_scorer_span_score/",
"/prompts/insert/",
"/prompts/fetch/",
"/prompts/tag/",
"/prompts/untag/",
"/prompts/get_prompt_versions/",
]


Expand Down
5 changes: 5 additions & 0 deletions scripts/openapi_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
"/projects/resolve/",
"/e2e_fetch_trace/",
"/e2e_fetch_span_score/",
"/prompts/insert/",
"/prompts/fetch/",
"/prompts/tag/",
"/prompts/untag/",
"/prompts/get_prompt_versions/",
]


Expand Down
128 changes: 128 additions & 0 deletions src/judgeval/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,69 @@ def upload_custom_scorer(
payload,
)

def prompts_insert(self, payload: PromptInsertRequest) -> PromptInsertResponse:
return self._request(
"POST",
url_for("/prompts/insert/"),
payload,
)

def prompts_tag(self, payload: PromptTagRequest) -> PromptTagResponse:
return self._request(
"POST",
url_for("/prompts/tag/"),
payload,
)

def prompts_untag(self, payload: PromptUntagRequest) -> PromptUntagResponse:
return self._request(
"POST",
url_for("/prompts/untag/"),
payload,
)

def prompts_fetch(
self,
name: str,
project_name: Optional[str] = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this require both? can we make the server endpoint only require project_Id? and we can resolve it locally and cache it once.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also can we make project_id only not optional

project_id: Optional[str] = None,
commit_id: Optional[str] = None,
tag: Optional[str] = None,
) -> PromptFetchResponse:
query_params = {}
if project_name is not None:
query_params["project_name"] = project_name
if project_id is not None:
query_params["project_id"] = project_id
query_params["name"] = name
if commit_id is not None:
query_params["commit_id"] = commit_id
if tag is not None:
query_params["tag"] = tag
return self._request(
"GET",
url_for("/prompts/fetch/"),
query_params,
)

def prompts_get_prompt_versions(
self,
name: str,
project_id: Optional[str] = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here can we make only project_Id mantatory

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

project_name: Optional[str] = None,
) -> PromptVersionsResponse:
query_params = {}
if project_id is not None:
query_params["project_id"] = project_id
if project_name is not None:
query_params["project_name"] = project_name
query_params["name"] = name
return self._request(
"GET",
url_for("/prompts/get_prompt_versions/"),
query_params,
)

def projects_resolve(
self, payload: ResolveProjectNameRequest
) -> ResolveProjectNameResponse:
Expand Down Expand Up @@ -381,6 +444,71 @@ async def upload_custom_scorer(
payload,
)

async def prompts_insert(
self, payload: PromptInsertRequest
) -> PromptInsertResponse:
return await self._request(
"POST",
url_for("/prompts/insert/"),
payload,
)

async def prompts_tag(self, payload: PromptTagRequest) -> PromptTagResponse:
return await self._request(
"POST",
url_for("/prompts/tag/"),
payload,
)

async def prompts_untag(self, payload: PromptUntagRequest) -> PromptUntagResponse:
return await self._request(
"POST",
url_for("/prompts/untag/"),
payload,
)

async def prompts_fetch(
self,
name: str,
project_name: Optional[str] = None,
project_id: Optional[str] = None,
commit_id: Optional[str] = None,
tag: Optional[str] = None,
) -> PromptFetchResponse:
query_params = {}
if project_name is not None:
query_params["project_name"] = project_name
if project_id is not None:
query_params["project_id"] = project_id
query_params["name"] = name
if commit_id is not None:
query_params["commit_id"] = commit_id
if tag is not None:
query_params["tag"] = tag
return await self._request(
"GET",
url_for("/prompts/fetch/"),
query_params,
)

async def prompts_get_prompt_versions(
self,
name: str,
project_id: Optional[str] = None,
project_name: Optional[str] = None,
) -> PromptVersionsResponse:
query_params = {}
if project_id is not None:
query_params["project_id"] = project_id
if project_name is not None:
query_params["project_name"] = project_name
query_params["name"] = name
return await self._request(
"GET",
url_for("/prompts/get_prompt_versions/"),
query_params,
)

async def projects_resolve(
self, payload: ResolveProjectNameRequest
) -> ResolveProjectNameResponse:
Expand Down
57 changes: 56 additions & 1 deletion src/judgeval/api/api_types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated by datamodel-codegen:
# filename: .openapi.json
# timestamp: 2025-10-09T00:16:42+00:00
# timestamp: 2025-10-12T05:03:53+00:00

from __future__ import annotations
from typing import Any, Dict, List, Literal, Optional, TypedDict, Union
Expand Down Expand Up @@ -88,6 +88,42 @@ class CustomScorerTemplateResponse(TypedDict):
message: str


class PromptInsertRequest(TypedDict):
project_name: NotRequired[Optional[str]]
project_id: NotRequired[Optional[str]]
name: str
prompt: str
tags: List[str]


class PromptInsertResponse(TypedDict):
commit_id: str
parent_commit_id: NotRequired[Optional[str]]


class PromptTagRequest(TypedDict):
project_name: NotRequired[Optional[str]]
project_id: NotRequired[Optional[str]]
name: str
commit_id: str
tags: List[str]


class PromptTagResponse(TypedDict):
commit_id: str


class PromptUntagRequest(TypedDict):
project_name: NotRequired[Optional[str]]
project_id: NotRequired[Optional[str]]
name: str
tags: List[str]


class PromptUntagResponse(TypedDict):
commit_id: str


class ResolveProjectNameRequest(TypedDict):
project_name: str

Expand Down Expand Up @@ -170,6 +206,17 @@ class PromptScorer(TypedDict):
is_trace: NotRequired[Optional[bool]]


class PromptCommitInfo(TypedDict):
name: str
prompt: str
tags: List[str]
commit_id: str
parent_commit_id: NotRequired[Optional[str]]
created_at: str
first_name: str
last_name: str


class ScorerData(TypedDict):
id: NotRequired[str]
name: str
Expand Down Expand Up @@ -266,6 +313,14 @@ class FetchPromptScorersResponse(TypedDict):
scorers: List[PromptScorer]


class PromptFetchResponse(TypedDict):
commit: NotRequired[Optional[PromptCommitInfo]]


class PromptVersionsResponse(TypedDict):
versions: List[PromptCommitInfo]


class ScoringResult(TypedDict):
success: bool
scorers_data: List[ScorerData]
Expand Down
57 changes: 56 additions & 1 deletion src/judgeval/data/judgment_types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated by datamodel-codegen:
# filename: .openapi.json
# timestamp: 2025-10-09T00:16:41+00:00
# timestamp: 2025-10-12T05:03:52+00:00

from __future__ import annotations
from typing import Annotated, Any, Dict, List, Optional, Union
Expand Down Expand Up @@ -95,6 +95,42 @@ class CustomScorerTemplateResponse(BaseModel):
message: Annotated[str, Field(title="Message")]


class PromptInsertRequest(BaseModel):
project_name: Annotated[Optional[str], Field(title="Project Name")] = None
project_id: Annotated[Optional[str], Field(title="Project Id")] = None
name: Annotated[str, Field(title="Name")]
prompt: Annotated[str, Field(title="Prompt")]
tags: Annotated[List[str], Field(title="Tags")]


class PromptInsertResponse(BaseModel):
commit_id: Annotated[str, Field(title="Commit Id")]
parent_commit_id: Annotated[Optional[str], Field(title="Parent Commit Id")] = None


class PromptTagRequest(BaseModel):
project_name: Annotated[Optional[str], Field(title="Project Name")] = None
project_id: Annotated[Optional[str], Field(title="Project Id")] = None
name: Annotated[str, Field(title="Name")]
commit_id: Annotated[str, Field(title="Commit Id")]
tags: Annotated[List[str], Field(title="Tags")]


class PromptTagResponse(BaseModel):
commit_id: Annotated[str, Field(title="Commit Id")]


class PromptUntagRequest(BaseModel):
project_name: Annotated[Optional[str], Field(title="Project Name")] = None
project_id: Annotated[Optional[str], Field(title="Project Id")] = None
name: Annotated[str, Field(title="Name")]
tags: Annotated[List[str], Field(title="Tags")]


class PromptUntagResponse(BaseModel):
commit_id: Annotated[str, Field(title="Commit Id")]


class ResolveProjectNameRequest(BaseModel):
project_name: Annotated[str, Field(title="Project Name")]

Expand Down Expand Up @@ -188,6 +224,17 @@ class PromptScorer(BaseModel):
is_trace: Annotated[Optional[bool], Field(title="Is Trace")] = False


class PromptCommitInfo(BaseModel):
name: Annotated[str, Field(title="Name")]
prompt: Annotated[str, Field(title="Prompt")]
tags: Annotated[List[str], Field(title="Tags")]
commit_id: Annotated[str, Field(title="Commit Id")]
parent_commit_id: Annotated[Optional[str], Field(title="Parent Commit Id")] = None
created_at: Annotated[str, Field(title="Created At")]
first_name: Annotated[str, Field(title="First Name")]
last_name: Annotated[str, Field(title="Last Name")]


class ScorerData(BaseModel):
id: Annotated[Optional[str], Field(title="Id")] = None
name: Annotated[str, Field(title="Name")]
Expand Down Expand Up @@ -300,6 +347,14 @@ class FetchPromptScorersResponse(BaseModel):
scorers: Annotated[List[PromptScorer], Field(title="Scorers")]


class PromptFetchResponse(BaseModel):
commit: Optional[PromptCommitInfo] = None


class PromptVersionsResponse(BaseModel):
versions: Annotated[List[PromptCommitInfo], Field(title="Versions")]


class ScoringResult(BaseModel):
success: Annotated[bool, Field(title="Success")]
scorers_data: Annotated[List[ScorerData], Field(title="Scorers Data")]
Expand Down
Loading
Loading