Skip to content

Commit

Permalink
Merge branch 'main' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
ritwik-g authored Jul 3, 2024
2 parents 6252b78 + d397063 commit 2fb2012
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ modules.xml
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
.python-version
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.9.0
1 change: 1 addition & 0 deletions backend/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.9.0
8 changes: 8 additions & 0 deletions backend/adapter_processor/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ class InValidAdapterId(APIException):
default_detail = "Adapter ID is not Valid."


class InvalidEncryptionKey(APIException):
status_code = 403
default_detail = (
"Platform encryption key for storing adapter credentials has changed! "
"Please inform the organization admin to contact support."
)


class InternalServiceError(APIException):
status_code = 500
default_detail = "Internal Service error"
Expand Down
8 changes: 6 additions & 2 deletions backend/adapter_processor/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from account.serializer import UserSerializer
from adapter_processor.adapter_processor import AdapterProcessor
from adapter_processor.constants import AdapterKeys
from cryptography.fernet import Fernet
from adapter_processor.exceptions import InvalidEncryptionKey
from cryptography.fernet import Fernet, InvalidToken
from django.conf import settings
from rest_framework import serializers
from rest_framework.serializers import ModelSerializer
Expand Down Expand Up @@ -62,7 +63,10 @@ def to_representation(self, instance: AdapterInstance) -> dict[str, str]:

rep.pop(AdapterKeys.ADAPTER_METADATA_B)

adapter_metadata = instance.get_adapter_meta_data()
try:
adapter_metadata = instance.get_adapter_meta_data()
except InvalidToken:
raise InvalidEncryptionKey
rep[AdapterKeys.ADAPTER_METADATA] = adapter_metadata
# Retrieve context window if adapter is a LLM
# For other adapter types, context_window is not relevant.
Expand Down
3 changes: 3 additions & 0 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ services:
- ../prompt-service/.env
labels:
- traefik.enable=false
extra_hosts:
# "host-gateway" is a special string that translates to host docker0 i/f IP.
- "host.docker.internal:host-gateway"

x2text-service:
image: unstract/x2text-service:${VERSION}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ function ConfigureConnectorModal({
activeKey={activeKey}
items={tabItems}
onChange={onTabChange}
moreIcon={<></>}
/>
{activeKey === "1" && (
<ConfigureFormsLayout
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/components/agency/side-panel/SidePanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ function SidePanel() {
return (
<div className="sidepanel-layout">
<div className="sidepanel-tabs">
<Tabs activeKey={activeTabKey} items={items} onChange={handleTabKey} />
<Tabs
activeKey={activeTabKey}
items={items}
onChange={handleTabKey}
moreIcon={<></>}
/>
</div>
<div className="sidepanel-content">
{activeTabKey === "1" && <Tools />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ function DocumentManager({ generateIndex, handleUpdateTool, handleDocChange }) {
activeKey={activeKey}
items={items}
onChange={handleActiveKeyChange}
moreIcon={<></>}
/>
</div>
<Space>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,12 @@ function ToolsMain() {
<div className="tools-main-layout">
<div className="doc-manager-header">
<div className="tools-main-tabs">
<Tabs activeKey={activeKey} items={items} onChange={onChange} />
<Tabs
activeKey={activeKey}
items={items}
onChange={onChange}
moreIcon={<></>}
/>
</div>
<div className="display-flex-align-center">
<Space>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ const DisplayCode = ({ isDialogOpen, setDialogOpen, url }) => {
}
onChange={handleTabKey}
items={TAB_ITEMS}
moreIcon={<></>}
/>
</Modal>
);
Expand Down
47 changes: 4 additions & 43 deletions platform-service/pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion platform-service/src/unstract/platform_service/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

import peewee
import requests
from unstract.platform_service.exceptions import CustomException, DBTableV2, FeatureFlag
from unstract.platform_service.constants import DBTableV2, FeatureFlag
from unstract.platform_service.exceptions import CustomException

from unstract.flags.feature_flag import check_feature_flag_status

Expand Down
11 changes: 4 additions & 7 deletions platform-service/src/unstract/platform_service/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@
PG_BE_DATABASE = os.environ.get("PG_BE_DATABASE")
ENCRYPTION_KEY = EnvManager.get_required_setting("ENCRYPTION_KEY")
MODEL_PRICES_URL = EnvManager.get_required_setting("MODEL_PRICES_URL")
MODEL_PRICES_TTL_IN_DAYS = int(
EnvManager.get_required_setting("MODEL_PRICES_TTL_IN_DAYS")
)
MODEL_PRICES_TTL_IN_DAYS = EnvManager.get_required_setting("MODEL_PRICES_TTL_IN_DAYS")
MODEL_PRICES_FILE_PATH = EnvManager.get_required_setting("MODEL_PRICES_FILE_PATH")

EnvManager.raise_for_missing_envs()
MODEL_PRICES_TTL_IN_DAYS = int(MODEL_PRICES_TTL_IN_DAYS)

# TODO: Follow Flask best practices and refactor accordingly
app = Flask("platform_service")
Expand Down Expand Up @@ -474,7 +472,7 @@ def custom_tool_instance() -> Any:
http://localhost:3001/db/custom_tool_instance/prompt_registry_id=id1
"""
bearer_token = get_token_from_auth_header(request)
organization_uid, organization_id = get_organization_from_bearer_token(bearer_token)
_, organization_id = get_organization_from_bearer_token(bearer_token)
if not organization_id:
return INVALID_ORGANIZATOIN, 403

Expand All @@ -486,7 +484,6 @@ def custom_tool_instance() -> Any:
db_instance=be_db,
organization_id=organization_id,
prompt_registry_id=prompt_registry_id,
organization_uid=organization_uid,
)
return jsonify(data_dict)
except Exception as e:
Expand All @@ -508,4 +505,4 @@ def handle_custom_exception(error: Any) -> tuple[Response, Any]:

if __name__ == "__main__":
# Start the server
app.run()
app.run(host="0.0.0.0", port="3001")
1 change: 1 addition & 0 deletions prompt-service/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.9.0
1 change: 0 additions & 1 deletion prompt-service/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
--bind 0.0.0.0:3003 \
--workers 2 \
--threads 2 \
--worker-class gevent\
--log-level debug \
--timeout 900 \
--access-logfile - \
Expand Down
2 changes: 2 additions & 0 deletions run-platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ build_services() {
}
elif [ "$first_setup" = true ] || [ "$opt_upgrade" = true ]; then
echo -e "$blue_text""Pulling""$default_text"" docker images tag ""$blue_text""$opt_version""$default_text""."
# Try again on a slow network.
VERSION=$opt_version $docker_compose_cmd -f $script_dir/docker/docker-compose.yaml pull ||
VERSION=$opt_version $docker_compose_cmd -f $script_dir/docker/docker-compose.yaml pull || {
echo -e "$red_text""Failed to pull docker images.""$default_text"
echo -e "$red_text""Either version not found or docker is not running.""$default_text"
Expand Down

0 comments on commit 2fb2012

Please sign in to comment.