-
Notifications
You must be signed in to change notification settings - Fork 913
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
103 additions
and
21 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from typing import Tuple, TypedDict | ||
from urllib.parse import urlencode, urlunparse | ||
|
||
from promptflow._utils.flow_utils import resolve_flow_path | ||
|
||
|
||
def construct_session_id(flow: str) -> str: | ||
from promptflow._sdk._service.utils.utils import encrypt_flow_path | ||
|
||
# Todo: use base64 encode for now, will consider whether need use encryption or use db to store flow path info | ||
return encrypt_flow_path(flow) | ||
|
||
|
||
def register_chat_session(flow: str, pfs_port, url_param: dict) -> Tuple[str, str]: | ||
# TODO: register chat session so that we may store related information in db and allow multiple | ||
# debug sessions on the same flow | ||
flow_dir, flow_file = resolve_flow_path(flow) | ||
session_id = construct_session_id((flow_dir / flow_file).absolute().resolve().as_posix()) | ||
query_params = urlencode({"flow": session_id, **url_param}) | ||
return session_id, urlunparse(("http", f"127.0.0.1:{pfs_port}", "/v1.0/ui/chat", "", query_params)) | ||
|
||
|
||
def get_info_for_flow_monitor(*, session_id, flow_dir) -> TypedDict["FlowInfo", {"hash": str}]: | ||
return { | ||
# TODO: calculate hash for flow file | ||
"hash": "hash", | ||
} |
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