-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #232 from Whitelisted1/master
Implemented tool capabilities
- Loading branch information
Showing
6 changed files
with
164 additions
and
72 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
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,33 @@ | ||
from .message import Conversation | ||
|
||
|
||
class File: | ||
''' | ||
Class used to represent files created by the model | ||
''' | ||
|
||
def __init__(self, sha: str, name: str, mime: str, conversation: Conversation): | ||
self.sha = sha | ||
self.name = name | ||
self.mime = mime | ||
|
||
self.conversation = conversation | ||
self.url = self.get_url() | ||
|
||
def get_url(self) -> str: | ||
""" | ||
Gets the url for the given file | ||
""" | ||
|
||
return f"https://huggingface.co/chat/conversation/{self.conversation.id}/output/{self.sha}" | ||
|
||
def download_file(self, chatBot) -> bytes: | ||
""" | ||
Downloads the given file | ||
""" | ||
|
||
r = chatBot.session.get(self.url) | ||
return r.content | ||
|
||
def __str__(self) -> str: | ||
return f"File(url={self.url}, sha={self.sha}, name={self.name}, mime={self.mime})" |
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,14 @@ | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class Tool: | ||
''' | ||
Class used to represent tools used by the model | ||
''' | ||
|
||
uuid: str | ||
result: str | ||
|
||
def __str__(self) -> str: | ||
return f"Tool(uuid={self.uuid}, result={self.result})" |
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
Oops, something went wrong.