mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-10-03 08:07:20 +00:00
fix(examples): update client usage to prefer await aclose() in async context" (#2839)
This commit is contained in:
@@ -57,12 +57,16 @@ async def main():
|
||||
# initialize client
|
||||
DBGPT_API_KEY = "dbgpt"
|
||||
client = Client(api_key=DBGPT_API_KEY)
|
||||
data = await client.chat(model="Qwen2.5-72B-Instruct", messages="hello")
|
||||
try:
|
||||
data = await client.chat(model="Qwen2.5-72B-Instruct", messages="hello")
|
||||
print(data)
|
||||
finally:
|
||||
# explicitly close client to avoid event loop closed error
|
||||
await client.aclose()
|
||||
# async for data in client.chat_stream(
|
||||
# model="chatgpt_proxyllm",
|
||||
# messages="hello",
|
||||
# ):
|
||||
print(data)
|
||||
|
||||
# res = await client.chat(model="chatgpt_proxyllm" ,messages="hello")
|
||||
# print(res)
|
||||
|
Reference in New Issue
Block a user