Skip to content

Commit

Permalink
Hotfix Chat url (#410)
Browse files Browse the repository at this point in the history
-[x] Fix chat role tag assignment 
-[x] Fix public-url construction by fixing URI formatting in the config
  • Loading branch information
EniasCailliau authored Jun 2, 2023
1 parent 3878d9f commit d1fb6e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions src/steamship/base/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import inflection
from pydantic import HttpUrl, SecretStr

from steamship.base.model import CamelModel
from steamship.base.model import CamelModel, to_camel
from steamship.cli.login import login
from steamship.utils.utils import format_uri

Expand Down Expand Up @@ -61,20 +61,21 @@ def __init__(
)
config_dict.update(self._get_config_dict_from_environment())
kwargs.update({k: v for k, v in config_dict.items() if kwargs.get(k) is None})
kwargs = {to_camel(k): v for k, v in kwargs.items()}

kwargs["api_base"] = format_uri(kwargs.get("api_base"))
kwargs["app_base"] = format_uri(kwargs.get("app_base"))
kwargs["web_base"] = format_uri(kwargs.get("web_base"))
kwargs["apiBase"] = format_uri(kwargs.get("apiBase"))
kwargs["appBase"] = format_uri(kwargs.get("appBase"))
kwargs["webBase"] = format_uri(kwargs.get("webBase"))

if not kwargs.get("api_key") and not kwargs.get("apiKey"):
if not kwargs.get("apiKey"):
api_key = login(
kwargs.get("api_base") or DEFAULT_API_BASE,
kwargs.get("web_base") or DEFAULT_WEB_BASE,
kwargs.get("apiBase") or DEFAULT_API_BASE,
kwargs.get("webBase") or DEFAULT_WEB_BASE,
)
Configuration._save_api_key_to_file(
api_key, profile, config_file or DEFAULT_CONFIG_FILE
)
kwargs["api_key"] = api_key
kwargs["apiKey"] = api_key

super().__init__(**kwargs)

Expand Down
2 changes: 1 addition & 1 deletion src/steamship/data/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def chat_role(self) -> Optional[RoleTag]:

def set_chat_role(self, role: RoleTag):
return self._one_time_set_tag(
tag_kind=DocTag.CHAT, tag_name=ChatTag.MESSAGE_ID, string_value=role.value
tag_kind=DocTag.CHAT, tag_name=ChatTag.ROLE, string_value=role.value
)

@property
Expand Down

0 comments on commit d1fb6e5

Please sign in to comment.