-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix/app-deployment-plugin' of https://github.com/Zipsta…
…ck/unstract into feat/app-deployment-with-multidoc-chat
- Loading branch information
Showing
78 changed files
with
5,127 additions
and
856 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,6 +132,7 @@ celerybeat.pid | |
*.sage.py | ||
|
||
# Environments | ||
test*.env | ||
.env | ||
.env.export | ||
.venv* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import logging | ||
|
||
from prompt_studio.prompt_studio.constants import ToolStudioPromptKeys | ||
from prompt_studio.prompt_studio.helper import PromptStudioHelper | ||
from prompt_studio.prompt_studio.models import ToolStudioPrompt | ||
from prompt_studio.prompt_studio.serializers import ReorderPromptsSerializer | ||
from rest_framework import status | ||
from rest_framework.request import Request | ||
from rest_framework.response import Response | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class PromptStudioController: | ||
def reorder_prompts(self, request: Request) -> Response: | ||
"""Reorder the sequence of prompts based on the start and end sequence | ||
numbers. | ||
This action handles the reordering of prompts by updating their sequence | ||
numbers. It increments or decrements the sequence numbers of the relevant | ||
prompts to reflect the new order. If the start and end sequence numbers | ||
are equal, it returns a bad request response. | ||
Args: | ||
request (Request): The HTTP request object containing the data to | ||
reorder prompts. | ||
Returns: | ||
Response: A Response object with the status of the reordering operation. | ||
""" | ||
try: | ||
# Validate request data | ||
serializer = ReorderPromptsSerializer(data=request.data) | ||
serializer.is_valid(raise_exception=True) | ||
|
||
# Extract validated data from the serializer | ||
start_sequence_number = serializer.validated_data.get( | ||
ToolStudioPromptKeys.START_SEQUENCE_NUMBER | ||
) | ||
end_sequence_number = serializer.validated_data.get( | ||
ToolStudioPromptKeys.END_SEQUENCE_NUMBER | ||
) | ||
prompt_id = serializer.validated_data.get(ToolStudioPromptKeys.PROMPT_ID) | ||
|
||
filtered_prompts_data = PromptStudioHelper.reorder_prompts_helper( | ||
prompt_id=prompt_id, | ||
start_sequence_number=start_sequence_number, | ||
end_sequence_number=end_sequence_number, | ||
) | ||
|
||
logger.info("Re-ordering completed successfully.") | ||
return Response(status=status.HTTP_200_OK, data=filtered_prompts_data) | ||
|
||
except ToolStudioPrompt.DoesNotExist: | ||
logger.error(f"Prompt with ID {prompt_id} not found.") | ||
return Response( | ||
status=status.HTTP_404_NOT_FOUND, data={"detail": "Prompt not found."} | ||
) |
Oops, something went wrong.