Skip to content

Commit

Permalink
Add base_url for post_message_attachment calls (#138)
Browse files Browse the repository at this point in the history
* Add base_url for post_message_attachment calls

* Add const for poe_api base url
  • Loading branch information
krisyang1125 authored Jan 16, 2025
1 parent 532737d commit c2c7fe5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/fastapi_poe/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
)

logger = logging.getLogger("uvicorn.default")
POE_API_WEBSERVER_BASE_URL = "https://www.quora.com/poe_api/"


class InvalidParameterError(Exception):
Expand Down Expand Up @@ -322,6 +323,7 @@ async def post_message_attachment(
filename: Optional[str] = None,
content_type: Optional[str] = None,
is_inline: bool = False,
base_url: str = POE_API_WEBSERVER_BASE_URL,
) -> AttachmentUploadResponse: ...

# This overload requires all parameters to be passed as keywords
Expand All @@ -336,6 +338,7 @@ async def post_message_attachment(
filename: Optional[str] = None,
content_type: Optional[str] = None,
is_inline: bool = False,
base_url: str = POE_API_WEBSERVER_BASE_URL,
) -> AttachmentUploadResponse: ...

async def post_message_attachment(
Expand All @@ -349,6 +352,7 @@ async def post_message_attachment(
filename: Optional[str] = None,
content_type: Optional[str] = None,
is_inline: bool = False,
base_url: str = POE_API_WEBSERVER_BASE_URL,
) -> AttachmentUploadResponse:
"""
Expand Down Expand Up @@ -386,6 +390,7 @@ async def post_message_attachment(
filename=filename,
content_type=content_type,
is_inline=is_inline,
base_url=base_url,
)
)
pending_tasks_for_message = self._pending_file_attachment_tasks.get(message_id)
Expand All @@ -409,6 +414,7 @@ async def _make_file_attachment_request(
filename: Optional[str] = None,
content_type: Optional[str] = None,
is_inline: bool = False,
base_url: str = POE_API_WEBSERVER_BASE_URL,
) -> AttachmentUploadResponse:
if self.access_key:
if access_key:
Expand All @@ -427,7 +433,7 @@ async def _make_file_attachment_request(
+ " provided with an access_key when make_app is called."
)
attachment_access_key = access_key
url = "https://www.quora.com/poe_api/file_attachment_3RD_PARTY_POST"
url = f"{base_url}file_attachment_3RD_PARTY_POST"

async with httpx.AsyncClient(timeout=120) as client:
try:
Expand Down

0 comments on commit c2c7fe5

Please sign in to comment.