Skip to content

Commit 257f088

Browse files
committed
feat: introduce HTTPMethod enum for improved method handling in http_client
1 parent ce639ec commit 257f088

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

mineru_vl_utils/vlm_client/http_client.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json
33
import os
44
import re
5+
from enum import Enum
56
from typing import AsyncIterable, Iterable, Sequence
67

78
import httpx
@@ -35,6 +36,16 @@ def _get_env(key: str, default: str | None = None) -> str:
3536
raise ValueError(f"Environment variable {key} is not set.")
3637

3738

39+
class HTTPMethod(str, Enum):
40+
HEAD = "HEAD"
41+
GET = "GET"
42+
PUT = "PUT"
43+
DELETE = "DELETE"
44+
OPTIONS = "OPTIONS"
45+
TRACE = "TRACE"
46+
POST = "POST"
47+
48+
3849
class HttpVlmClient(VlmClient):
3950
def __init__(
4051
self,
@@ -120,6 +131,7 @@ def _new_client(self) -> httpx.Client:
120131
retry=Retry(
121132
total=self.max_retries,
122133
backoff_factor=self.retry_backoff_factor,
134+
allowed_methods=list(HTTPMethod),
123135
),
124136
transport=httpx.HTTPTransport(
125137
limits=httpx.Limits(
@@ -144,6 +156,7 @@ async def _new_aio_client(self) -> httpx.AsyncClient:
144156
retry=Retry(
145157
total=self.max_retries,
146158
backoff_factor=self.retry_backoff_factor,
159+
allowed_methods=list(HTTPMethod),
147160
),
148161
transport=httpx.AsyncHTTPTransport(
149162
limits=httpx.Limits(

0 commit comments

Comments
 (0)