Skip to content

Commit e31b618

Browse files
Merge pull request #427 from aiverify-foundation/dev_main
[Sprint 22] New features and fixes
2 parents 43f75f7 + 840bb16 commit e31b618

File tree

93 files changed

+4876
-2531
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+4876
-2531
lines changed

examples/jupyter-notebook/Moonshot - Benchmark Feature Walkthrough.ipynb

Lines changed: 1016 additions & 314 deletions
Large diffs are not rendered by default.

moonshot/integrations/cli/__main__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import sys
21
import warnings
32

43
from moonshot.integrations.cli.cli import CommandLineInterface
54

65

7-
def start_app(cli_command = None):
6+
def start_app(cli_command=None):
87
"""
98
Run the Moonshot application
109
"""
@@ -22,4 +21,3 @@ def start_app(cli_command = None):
2221
else:
2322
# Show help if no command is provided
2423
cli_instance.onecmd("help")
25-

moonshot/integrations/cli/redteam/session.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def new_session(args) -> None:
5858
- context_strategy (str, optional): The context strategy to be used.
5959
- prompt_template (str, optional): The prompt template to be used.
6060
- endpoints (str, optional): The list of endpoints for the runner."""
61-
global active_session
61+
global active_session # noqa: F824
6262

6363
try:
6464
required_parameters = [("runner_id", str)]
@@ -136,7 +136,7 @@ def use_session(args) -> None:
136136
Args:
137137
args (Namespace): The arguments passed to the function.
138138
"""
139-
global active_session
139+
global active_session # noqa: F824
140140

141141
# Load session metadata
142142
try:
@@ -168,7 +168,7 @@ def show_prompts() -> None:
168168
"""
169169
Shows the chat table in a session so that users don't have to restart a session to view the chat table
170170
"""
171-
global active_session
171+
global active_session # noqa: F824
172172

173173
if not active_session:
174174
print(ERROR_RED_TEAMING_SHOW_PROMPTS_NO_ACTIVE_SESSION_VALIDATION)
@@ -181,7 +181,7 @@ def end_session() -> None:
181181
"""
182182
Ends the current session by clearing active_session variable.
183183
"""
184-
global active_session
184+
global active_session # noqa: F824
185185
active_session.clear()
186186

187187

@@ -249,7 +249,7 @@ def update_chat_display() -> None:
249249
The table includes columns for the chat ID, prepared prompts, and the prompt/response pairs.
250250
If there is no active session, a message is printed to the console.
251251
"""
252-
global active_session
252+
global active_session # noqa: F824
253253

254254
if active_session:
255255
list_of_endpoint_chats = api_get_all_chats_from_session(
@@ -311,7 +311,7 @@ def add_bookmark(args) -> None:
311311
312312
If there is no active session, a message is printed to the console and the function returns.
313313
"""
314-
global active_session
314+
global active_session # noqa: F824
315315

316316
if active_session:
317317
try:
@@ -372,7 +372,7 @@ def use_bookmark(args) -> None:
372372
373373
If there is no active session, a message is printed to the console and the function returns.
374374
"""
375-
global active_session
375+
global active_session # noqa: F824
376376
if active_session:
377377
try:
378378
bookmark_name = args.bookmark_name
@@ -747,7 +747,7 @@ def _reload_session(runner_id: str) -> None:
747747
Args:
748748
runner_id (str): The ID of the runner for which the session metadata needs to be reloaded.
749749
"""
750-
global active_session
750+
global active_session # noqa: F824
751751
try:
752752
session_metadata = api_load_session(runner_id)
753753
if not session_metadata:

moonshot/integrations/web_api/routes/benchmark_result.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ async def get_one_results(
131131
status_code=500, detail=f"Failed to retrieve result: {e.msg}"
132132
)
133133

134+
134135
@router.delete("/api/v1/benchmarks/results/{result_id}")
135136
@inject
136137
def delete_result(

moonshot/integrations/web_api/routes/bookmark.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
from typing import Optional
32

43
from dependency_injector.wiring import Provide, inject
@@ -138,6 +137,8 @@ def delete_bookmark(
138137
raise HTTPException(
139138
status_code=500, detail=f"Failed to delete bookmark: {e.msg}"
140139
)
140+
141+
141142
@router.get(
142143
"/api/v1/bookmarks/export", response_description="Exporting Bookmark to JSON file"
143144
)
@@ -160,7 +161,9 @@ def export_bookbookmarks(
160161
"""
161162
try:
162163
file_path = bookmark_service.export_bookmarks(export_file_name)
163-
return FileResponse(file_path, media_type="application/json", filename=export_file_name)
164+
return FileResponse(
165+
file_path, media_type="application/json", filename=export_file_name
166+
)
164167
except ServiceException as e:
165168
if e.error_code == "FileNotFound":
166169
raise HTTPException(

moonshot/integrations/web_api/routes/context_strategy.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
router = APIRouter(tags=["Context Strategy"])
99

10+
1011
@router.get("/api/v1/context-strategies")
1112
@inject
1213
def get_all_context_strategies(
@@ -46,7 +47,8 @@ def get_all_context_strategies(
4647
status_code=500,
4748
detail=f"Failed to retrieve context strategies: {e.msg}",
4849
)
49-
50+
51+
5052
@router.get("/api/v1/context-strategies/name")
5153
@inject
5254
def get_all_context_strategies_name(

moonshot/integrations/web_api/routes/prompt_template.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def get_all_prompt_templates_names(
8787
detail=f"Failed to retrieve prompt template names: {e.msg}",
8888
)
8989

90+
9091
@router.delete("/api/v1/prompt-templates/{prompt_template_name}")
9192
@inject
9293
def delete_prompt_template(

moonshot/integrations/web_api/schemas/cookbook_create_dto.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from typing import Optional
22

3+
from pydantic import Field
4+
35
from moonshot.src.cookbooks.cookbook_arguments import (
46
CookbookArguments as CookbookPydanticModel,
57
)
6-
from pydantic import Field
8+
79

810
class CookbookCreateDTO(CookbookPydanticModel):
911
id: Optional[str] = None
@@ -20,4 +22,4 @@ class CookbookUpdateDTO(CookbookPydanticModel):
2022
description: Optional[str] = Field(default=None, min_length=1)
2123
tags: Optional[list[str]] = None
2224
categories: Optional[list[str]] = None
23-
recipes: Optional[list[str]] = Field(default=None, min_length=1)
25+
recipes: Optional[list[str]] = Field(default=None, min_length=1)

moonshot/integrations/web_api/schemas/prompt_response_model.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from ..schemas.session_response_model import ChatRecord
44

55

6-
76
class PromptInfo(BaseModel):
87
current_runner_id: str
98
current_chats: dict[str, list[ChatRecord]]

moonshot/integrations/web_api/schemas/recipe_create_dto.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from typing import Optional
22

3+
from pydantic import Field
4+
35
from moonshot.src.recipes.recipe_arguments import RecipeArguments as RecipePydanticModel
46

5-
from pydantic import Field
67

78
class RecipeCreateDTO(RecipePydanticModel):
89
id: Optional[str] = None

0 commit comments

Comments
 (0)