-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/remote-storage-v2
- Loading branch information
Showing
40 changed files
with
1,122 additions
and
538 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
This file was deleted.
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
46 changes: 46 additions & 0 deletions
46
backend/prompt_studio/prompt_studio_output_manager_v2/output_manager_util.py
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,46 @@ | ||
from django.db.models import Count | ||
from prompt_studio.prompt_studio_output_manager_v2.models import ( | ||
PromptStudioOutputManager, | ||
) | ||
|
||
|
||
class OutputManagerUtils: | ||
@staticmethod | ||
def get_coverage( | ||
tool_id: str, profile_manager_id: str, prompt_id: str = None | ||
) -> dict[str, int]: | ||
""" | ||
Method to fetch coverage data for given tool and profile manager. | ||
Args: | ||
tool (CustomTool): The tool instance or ID for which coverage is fetched. | ||
profile_manager_id (str): The ID of the profile manager | ||
for which coverage is calculated. | ||
prompt_id (Optional[str]): The ID of the prompt (optional). | ||
If provided, coverage is fetched for the specific prompt. | ||
Returns: | ||
dict[str, int]: A dictionary containing coverage information. | ||
Keys are formatted as "coverage_<prompt_id>_<profile_manager_id>". | ||
Values are the count of documents associated with each prompt | ||
and profile combination. | ||
""" | ||
|
||
prompt_outputs = ( | ||
PromptStudioOutputManager.objects.filter( | ||
tool_id=tool_id, | ||
profile_manager_id=profile_manager_id, | ||
**({"prompt_id": prompt_id} if prompt_id else {}), | ||
) | ||
.values("prompt_id", "profile_manager_id") | ||
.annotate(document_count=Count("document_manager_id")) | ||
) | ||
|
||
coverage = {} | ||
for prompt_output in prompt_outputs: | ||
prompt_key = str(prompt_output["prompt_id"]) | ||
profile_key = str(prompt_output["profile_manager_id"]) | ||
coverage[f"coverage_{prompt_key}_{profile_key}"] = prompt_output[ | ||
"document_count" | ||
] | ||
return coverage |
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
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,9 @@ | ||
# Unstract DB Setup Script | ||
|
||
[The db_setup.sh](/docker/scripts/db-setup/db_setup.sh) script helps setup the postgres database by making use of environment variables defined in the `.essentials.env` (user copy of the [sample.essentials.env](/docker/sample.essentials.env)) | ||
|
||
- POSTGRES_USER | ||
- POSTGRES_DB | ||
- POSTGRES_SCHEMA | ||
|
||
This script helps setup the DB user and creates a new schema as well. |
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,12 @@ | ||
#!/bin/bash | ||
echo "Creating DB '$POSTGRES_DB' and schema '$POSTGRES_SCHEMA' with user '$POSTGRES_USER'" | ||
|
||
psql -U ${POSTGRES_USER} -d ${POSTGRES_DB}<<-END | ||
ALTER ROLE ${POSTGRES_USER} SET client_encoding TO 'utf8'; | ||
ALTER ROLE ${POSTGRES_USER} SET default_transaction_isolation TO 'read committed'; | ||
ALTER ROLE ${POSTGRES_USER} SET timezone TO 'UTC'; | ||
ALTER USER ${POSTGRES_USER} CREATEDB; | ||
CREATE DATABASE ${POSTGRES_DB}; | ||
GRANT ALL PRIVILEGES ON DATABASE ${POSTGRES_DB} TO ${POSTGRES_USER}; | ||
CREATE SCHEMA IF NOT EXISTS ${POSTGRES_SCHEMA} | ||
END |
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
Oops, something went wrong.