mistralai / client-python

Python client library for Mistral AI platform
Apache License 2.0
485 stars 106 forks source link

[BUG CLIENT]: Header set on the async_client are not taken into account #141

Open jerome-quere opened 2 months ago

jerome-quere commented 2 months ago

Python -VV

Python 3.12.5 (main, Aug  6 2024, 19:08:49) [Clang 15.0.0 (clang-1500.3.9.4)]

Pip Freeze

aiohappyeyeballs==2.4.0
aiohttp==3.10.5
aiosignal==1.3.1
annotated-types==0.7.0
anthropic==0.34.2
anyio==4.4.0
asyncpg==0.29.0
attrs==24.2.0
bodyguard-protobuf==2024.9.3.post1
bodyguard-toolbox==0.26.0
certifi==2024.8.30
charset-normalizer==3.3.2
coloredlogs==15.0.1
distro==1.9.0
Faker==28.4.1
filelock==3.15.4
frozenlist==1.4.1
fsspec==2024.9.0
googleapis-common-protos==1.65.0
greenlet==3.0.3
grpcio==1.66.1
grpcio-health-checking==1.62.3
grpcio-reflection==1.62.3
h11==0.14.0
h2==4.1.0
hpack==4.0.0
httpcore==1.0.5
httpx==0.27.2
huggingface-hub==0.24.6
humanfriendly==10.0
hyperframe==6.0.1
idna==3.8
ijson==3.3.0
iniconfig==2.0.0
Jinja2==3.1.4
jiter==0.5.0
jsonpath-python==1.0.6
jsonschema==4.23.0
jsonschema-specifications==2023.12.1
-e git+ssh://git@github.com/bodyguard-ai/llm.git@c3cfc657b73d5bb0c44403e17694d6e7dbc16a8e#egg=llm
MarkupSafe==2.1.5
mistralai==1.0.3
multidict==6.0.5
mypy==1.11.2
mypy-extensions==1.0.0
openai==1.44.0
orjson==3.10.7
packaging==24.1
pastel==0.2.1
pluggy==1.5.0
poethepoet==0.27.0
prometheus_client==0.20.0
protobuf==4.25.4
psycopg2==2.9.9
pydantic==2.8.2
pydantic_core==2.20.1
pytest==8.3.2
pytest-asyncio==0.23.8
pytest-mock==3.14.0
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
python-json-logger==2.0.7
PyYAML==6.0.2
redis==5.0.8
referencing==0.35.1
requests==2.32.3
rpds-py==0.20.0
ruff==0.5.7
sentry-sdk==2.13.0
six==1.16.0
sniffio==1.3.1
SQLAlchemy==2.0.34
tokenizers==0.20.0
tomli==2.0.1
tqdm==4.66.5
types-protobuf==5.27.0.20240626
typing-inspect==0.9.0
typing_extensions==4.12.2
urllib3==2.2.2
xds-protos==1.62.3
yarl==1.9.11

Reproduction Steps

client = Mistral(
  async_client=httpx.AsyncClient(headers={"Custom-Header": "Value"}),
  server_url=base_url,
)

client.chat.complete_async(...) 

Expected Behavior

Header Custom-Header should be passed when making the call to the API

Additional Context

No response

Suggested Solutions

Issue is probably link to this line that call build_request without giving context wether or not it's an async call. In the implementation of build_request the request is always created using client = self.sdk_configuration.client even if we are making an async request.