Skip to content

Commit

Permalink
Merge pull request #145 from F33RNI/next
Browse files Browse the repository at this point in the history
Minor bug fix
  • Loading branch information
F33RNI committed Mar 9, 2024
2 parents 234442a + 12c7300 commit 7efce66
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 43 deletions.
2 changes: 1 addition & 1 deletion _version.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from packaging import version

__version__ = "5.0.0"
__version__ = "5.0.1"


def version_major() -> int:
Expand Down
4 changes: 4 additions & 0 deletions ms_copilot_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ async def async_ask_stream_():
if author is None or author != "bot":
continue

# Ignore internal messages
if message.get("messageType") is not None:
continue

# Text response
text = message.get("text")
if text:
Expand Down
58 changes: 16 additions & 42 deletions request_response_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
class RequestResponseContainer:
def __init__(
self,
user_id: str,
user_id: int,
reply_message_id: int,
module_name: str,
request_text: str or None = None,
Expand All @@ -54,49 +54,23 @@ def __init__(
reply_markup: InlineKeyboardMarkup or None = None,
pid: int = 0,
) -> None:
"""TODO: Universal request-response wrapper
"""_summary_
Args:
user (str): ID of user
reply_message_id (int): ID of message reply to
processing_state (str, optional): PROCESSING_STATE_.... Defaults to PROCESSING_STATE_IN_QUEUE
message_id (int, optional): current message ID (for editing aka live replying). Defaults to -1
request (str, optional): text request. Defaults to ""
response (str, optional): text response. Defaults to ""
response_images (type, optional): Images in the responses.
Defaults to None.
request_type (type, optional): REQUEST_TYPE_CHATGPT / REQUEST_TYPE_DALLE / ...
Defaults to REQUEST_TYPE_CHATGPT.
request_timestamp (str, optional): Timestamp of request (for data collecting).
FORMATTED
Defaults to "".
response_timestamp (str, optional): Timestamp of response (for data collecting).
Defaults to "".
response_send_timestamp_last (int, optional): Timestamp of last response (for editing aka live replying).
Defaults to 0.
reply_markup (type, optional): Message buttons.
Defaults to None.
pid (int, optional): Current multiprocessing process PID for handling this container.
Defaults to 0.
image_url (type, optional): URL of the photo inside the message.
Defaults to None.
logging.info("Downloading user image")
image = requests.get(request_response.image_url, timeout=120)
logging.info("Asking Gemini...")
response = self._vision_model.generate_content(
[
Part(
inline_data={
"mime_type": "image/jpeg",
"data": image.content,
}
),
Part(text=request_response.request),
],
stream=True,
)
user_id (int): ID of the user
reply_message_id (int): ID of user's message (to reply on)
module_name (str): name of requested module ("lmao_chatgpt", "gemini", etc.)
request_text (str or None, optional): user's request text
request_image (bytes or None, optional): user's request image as bytes
request_timestamp (str or None, optional): formatted time of the request
response_text (str or None, optional): module's response text
response_images (List[str] or None, optional): links to images of module's response
response_timestamp (str or None, optional): formatted time of final response
response_send_timestamp_last (float, optional): timestamp of last response (for editing aka live replying)
processing_state (int, optional): state of container. Defaults to PROCESSING_STATE_IN_QUEUE
message_id (int, optional): id or response message (after sending it, for editing)
reply_markup (InlineKeyboardMarkup or None, optional): message buttons
pid (int, optional): PID of module's process
"""
# Required args
self.user_id = user_id
Expand Down

0 comments on commit 7efce66

Please sign in to comment.