Skip to content

Commit

Permalink
perf: get_conversation_info() supports to pass conversation id
Browse files Browse the repository at this point in the history
  • Loading branch information
Soulter committed May 31, 2024
1 parent e766d7e commit 909de44
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/hugchat/hugchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,14 +504,18 @@ def get_remote_conversations(self, replace_conversation_list=True):

return conversations

def get_conversation_info(self, conversation: Conversation = None) -> Conversation:
def get_conversation_info(self, conversation: Union[Conversation, str] = None) -> Conversation:
"""
Fetches information related to the specified conversation. Returns the conversation object.
conversation: Conversation object that has the conversation id Or None to use the current conversation.
"""

if conversation is None:
conversation = self.current_conversation

if isinstance(conversation, str):
conversation = Conversation(id=conversation)

r = self.session.get(
self.hf_base_url +
f"/chat/conversation/{conversation.id}/__data.json?x-sveltekit-invalidated=01",
Expand Down Expand Up @@ -608,6 +612,7 @@ def get_assistant_list_by_page(self, page: int) -> List[Assistant]:

def search_assistant(self, assistant_name: str = None, assistant_id: str = None) -> Assistant:
'''
- If you created an assistant by your own, you should pass the assistant_id here but not the assistant_name. You can pass your assistant_id into the new_conversation() directly.
- Search an available assistant by assistant name or assistant id.
- Will search on api.soulter.top/hugchat because offifial api doesn't support search.
- Return the `Assistant` object if found, return None if not found.
Expand Down

0 comments on commit 909de44

Please sign in to comment.