Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/multi llm enhancement #412

Merged
merged 62 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
dec7c3b
added multiple llm profiles
jagadeeswaran-zipstack Jun 18, 2024
a7d2b99
made changes in coverage and combined output
jagadeeswaran-zipstack Jun 18, 2024
e8f66ec
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 18, 2024
ae9105a
sonar lint fix
jagadeeswaran-zipstack Jun 19, 2024
19b1c5c
Merge branch 'FEAT/multi-llm-enhancement' of github.com:Zipstack/unst…
jagadeeswaran-zipstack Jun 19, 2024
42fb895
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 19, 2024
6300c14
added index output viewer
jagadeeswaran-zipstack Jun 19, 2024
14a8bcf
Merge branch 'FEAT/multi-llm-enhancement' of github.com:Zipstack/unst…
jagadeeswaran-zipstack Jun 19, 2024
6a9ffe7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 19, 2024
87472f4
pre-commit fixes
jagadeeswaran-zipstack Jun 20, 2024
f8afb4d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 20, 2024
2b55564
pre-commit fixes
jagadeeswaran-zipstack Jun 20, 2024
5155497
Merge branch 'FEAT/multi-llm-enhancement' of github.com:Zipstack/unst…
jagadeeswaran-zipstack Jun 20, 2024
c210923
added timer and profile info bar
jagadeeswaran-zipstack Jun 20, 2024
2204036
Merge branch 'main' of github.com:Zipstack/unstract into FEAT/multi-l…
jagadeeswaran-zipstack Jun 20, 2024
d7271ba
added profile limit
jagadeeswaran-zipstack Jun 20, 2024
ff9fe34
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 20, 2024
ffeee88
Trigger Build
jagadeeswaran-zipstack Jun 20, 2024
953349a
code clean up
jagadeeswaran-zipstack Jun 21, 2024
da06669
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 21, 2024
893bdb8
code clean up
jagadeeswaran-zipstack Jun 21, 2024
aea367b
Merge branch 'FEAT/multi-llm-enhancement' of github.com:Zipstack/unst…
jagadeeswaran-zipstack Jun 21, 2024
1b4367b
code optimization
jagadeeswaran-zipstack Jun 24, 2024
6f1b3be
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 24, 2024
2736986
removed unwanted f-strings
jagadeeswaran-zipstack Jun 24, 2024
a205033
Merge branch 'FEAT/multi-llm-enhancement' of github.com:Zipstack/unst…
jagadeeswaran-zipstack Jun 24, 2024
b2ab964
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 24, 2024
942c96f
added ttl to settings and updated sample.env
jagadeeswaran-zipstack Jun 25, 2024
7f579a8
Merge branch 'FEAT/multi-llm-enhancement' of github.com:Zipstack/unst…
jagadeeswaran-zipstack Jun 25, 2024
9088beb
added types for func
jagadeeswaran-zipstack Jun 26, 2024
edc4022
single pass fix
jagadeeswaran-zipstack Jun 27, 2024
59e024c
Merge branch 'main' of github.com:Zipstack/unstract into FEAT/multi-l…
jagadeeswaran-zipstack Jun 27, 2024
8ba2627
added total cost and context to UI
jagadeeswaran-zipstack Jun 27, 2024
c760a6e
code refactor
jagadeeswaran-zipstack Jun 27, 2024
ffc6420
fix sonar issue
jagadeeswaran-zipstack Jun 27, 2024
29ad0d2
code refactor
jagadeeswaran-zipstack Jun 27, 2024
131c9fc
code refactor
jagadeeswaran-zipstack Jun 27, 2024
42831af
FE build fix
jagadeeswaran-zipstack Jun 27, 2024
3f86aff
re-index fix
jagadeeswaran-zipstack Jun 28, 2024
ccb3969
remove defaults for env
jagadeeswaran-zipstack Jun 28, 2024
f119d0a
changed display text for chuck
jagadeeswaran-zipstack Jun 28, 2024
283109e
Merge branch 'main' into FEAT/multi-llm-enhancement
jagadeeswaran-zipstack Jun 28, 2024
4782a84
code refactor
jagadeeswaran-zipstack Jun 28, 2024
d9ae4e4
Merge branch 'FEAT/multi-llm-enhancement' of github.com:Zipstack/unst…
jagadeeswaran-zipstack Jun 28, 2024
58d87f3
code refactor
jagadeeswaran-zipstack Jun 28, 2024
9268899
Update backend/prompt_studio/prompt_studio_core/views.py
chandrasekharan-zipstack Jun 28, 2024
56b109e
changed context db type to textfield
jagadeeswaran-zipstack Jun 30, 2024
52bdc24
Merge branch 'FEAT/multi-llm-enhancement' of github.com:Zipstack/unst…
jagadeeswaran-zipstack Jun 30, 2024
54f9d3a
Merge branch 'main' into FEAT/multi-llm-enhancement
nehabagdia Jul 2, 2024
2552f58
Merge branch 'main' of github.com:Zipstack/unstract into FEAT/multi-l…
jagadeeswaran-zipstack Jul 3, 2024
62ca5e2
simple prompt studio compatability fix
jagadeeswaran-zipstack Jul 3, 2024
afd9a18
Merge branch 'FEAT/multi-llm-enhancement' of github.com:Zipstack/unst…
jagadeeswaran-zipstack Jul 3, 2024
394210a
moved polling to FE
jagadeeswaran-zipstack Jul 3, 2024
7a2b92d
sonar fix
jagadeeswaran-zipstack Jul 3, 2024
3791bd4
sonar fix for nesting
jagadeeswaran-zipstack Jul 3, 2024
2d44a17
move polling to static func
jagadeeswaran-zipstack Jul 3, 2024
5d18ac2
added enum for index status
jagadeeswaran-zipstack Jul 4, 2024
65fa454
Merge branch 'main' into FEAT/multi-llm-enhancement
jagadeeswaran-zipstack Jul 4, 2024
f4c8ac3
reduced timeout value for polling
jagadeeswaran-zipstack Jul 5, 2024
0b2d124
Merge branch 'FEAT/multi-llm-enhancement' of github.com:Zipstack/unst…
jagadeeswaran-zipstack Jul 5, 2024
cbc60cd
FE code cleanup
jagadeeswaran-zipstack Jul 5, 2024
d438d8e
Merge branch 'main' into FEAT/multi-llm-enhancement
tahierhussain Jul 8, 2024
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
4 changes: 4 additions & 0 deletions backend/adapter_processor/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ def to_representation(self, instance: AdapterInstance) -> dict[str, str]:
rep[common.ICON] = AdapterProcessor.get_adapter_data_with_key(
instance.adapter_id, common.ICON
)
adapter_metadata = instance.get_adapter_meta_data()
model = adapter_metadata.get("model")
if model:
rep["model"] = model

if instance.is_friction_less:
rep["created_by_email"] = "Unstract"
Expand Down
1 change: 1 addition & 0 deletions backend/backend/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def get_required_setting(
"CELERY_BROKER_URL", f"redis://{REDIS_HOST}:{REDIS_PORT}"
)

INDEXING_FLAG_TTL = int(get_required_setting("INDEXING_FLAG_TTL"))
# Flag to Enable django admin
ADMIN_ENABLED = False

Expand Down
2 changes: 2 additions & 0 deletions backend/prompt_studio/prompt_profile_manager/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class ProfileManagerKeys:
VECTOR_STORE = "vector_store"
EMBEDDING_MODEL = "embedding_model"
X2TEXT = "x2text"
PROMPT_STUDIO_TOOL = "prompt_studio_tool"
MAX_PROFILE_COUNT = 4


class ProfileManagerErrors:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from prompt_studio.prompt_profile_manager.models import ProfileManager


class ProfileManagerHelper:

@classmethod
def get_profile_manager(cls, profile_manager_id: str) -> ProfileManager:
try:
return ProfileManager.objects.get(profile_id=profile_manager_id)
except ProfileManager.DoesNotExist:
raise ValueError("ProfileManager does not exist.")
13 changes: 13 additions & 0 deletions backend/prompt_studio/prompt_profile_manager/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from adapter_processor.adapter_processor import AdapterProcessor
from prompt_studio.prompt_profile_manager.constants import ProfileManagerKeys
from prompt_studio.prompt_studio_core.exceptions import MaxProfilesReachedError

from backend.serializers import AuditSerializer

Expand Down Expand Up @@ -38,3 +39,15 @@ def to_representation(self, instance): # type: ignore
AdapterProcessor.get_adapter_instance_by_id(x2text)
)
return rep

def validate(self, data):
prompt_studio_tool = data.get(ProfileManagerKeys.PROMPT_STUDIO_TOOL)

profile_count = ProfileManager.objects.filter(
prompt_studio_tool=prompt_studio_tool
).count()

if profile_count >= ProfileManagerKeys.MAX_PROFILE_COUNT:
raise MaxProfilesReachedError()

return data
10 changes: 10 additions & 0 deletions backend/prompt_studio/prompt_studio_core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ class ToolStudioPromptKeys:
NOTES = "NOTES"
OUTPUT = "output"
SEQUENCE_NUMBER = "sequence_number"
PROFILE_MANAGER_ID = "profile_manager"
CONTEXT = "context"
METADATA = "metadata"


class FileViewTypes:
Expand All @@ -108,6 +111,13 @@ class LogLevel(Enum):
FATAL = "FATAL"


class IndexingStatus(Enum):
PENDING_STATUS = "pending"
COMPLETED_STATUS = "completed"
STARTED_STATUS = "started"
DOCUMENT_BEING_INDEXED = "Document is being indexed"


class DefaultPrompts:
PREAMBLE = (
"Your ability to extract and summarize this context accurately "
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from typing import Optional

from django.conf import settings
from prompt_studio.prompt_studio_core.constants import IndexingStatus
from utils.cache_service import CacheService


class DocumentIndexingService:
CACHE_PREFIX = "document_indexing:"

@classmethod
def set_document_indexing(cls, org_id: str, user_id: str, doc_id_key: str) -> None:
jagadeeswaran-zipstack marked this conversation as resolved.
Show resolved Hide resolved
CacheService.set_key(
cls._cache_key(org_id, user_id, doc_id_key),
IndexingStatus.STARTED_STATUS.value,
expire=settings.INDEXING_FLAG_TTL,
)

@classmethod
def is_document_indexing(cls, org_id: str, user_id: str, doc_id_key: str) -> bool:
return (
CacheService.get_key(cls._cache_key(org_id, user_id, doc_id_key))
== IndexingStatus.STARTED_STATUS.value
)

@classmethod
def mark_document_indexed(
cls, org_id: str, user_id: str, doc_id_key: str, doc_id: str
) -> None:
CacheService.set_key(
cls._cache_key(org_id, user_id, doc_id_key),
doc_id,
expire=settings.INDEXING_FLAG_TTL,
)

@classmethod
def get_indexed_document_id(
cls, org_id: str, user_id: str, doc_id_key: str
) -> Optional[str]:
result = CacheService.get_key(cls._cache_key(org_id, user_id, doc_id_key))
if result and result != IndexingStatus.STARTED_STATUS.value:
return result
return None

@classmethod
def remove_document_indexing(
cls, org_id: str, user_id: str, doc_id_key: str
) -> None:
CacheService.delete_a_key(cls._cache_key(org_id, user_id, doc_id_key))

@classmethod
def _cache_key(cls, org_id: str, user_id: str, doc_id_key: str) -> str:
return f"{cls.CACHE_PREFIX}{org_id}:{user_id}:{doc_id_key}"
9 changes: 9 additions & 0 deletions backend/prompt_studio/prompt_studio_core/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from prompt_studio.prompt_profile_manager.constants import ProfileManagerKeys
from prompt_studio.prompt_studio_core.constants import ToolStudioErrors
from rest_framework.exceptions import APIException

Expand Down Expand Up @@ -58,3 +59,11 @@ class PermissionError(APIException):
class EmptyPromptError(APIException):
status_code = 422
default_detail = "Prompt(s) cannot be empty"


class MaxProfilesReachedError(APIException):
status_code = 403
default_detail = (
f"Maximum number of profiles (max {ProfileManagerKeys.MAX_PROFILE_COUNT})"
" per prompt studio project has been reached."
)
Loading
Loading