Open underthesand opened 1 month ago
Hello, there is no way to retrieve the tokens used (usage) with Azure when using streaming and structured_output.
structured_llm = llm.with_structured_output(Joke, include_raw=True) for chunk in structured_llm.stream("Tell me a joke about cats") print(chunk)
https://python.langchain.com/docs/how_to/structured_output/
No response
This code disables streaming. We have to wait for the complete generation to get a response.
Expected behavior: We should be able to use streaming and retrieve the usage metadata at the end.
OS: Linux OS Version: #47~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Oct 2 16:16:55 UTC 2 Python Version: 3.11.10 | packaged by conda-forge | (main, Sep 22 2024, 14:10:38) [GCC 13.3.0]
langchain_core: 0.3.12 langchain: 0.3.3 langsmith: 0.1.128 langchain_openai: 0.2.2 langchain_text_splitters: 0.3.0
langgraph langserve
aiohttp: 3.9.5 async-timeout: Installed. No version info available. httpx: 0.27.0 jsonpatch: 1.33 numpy: 1.26.4 openai: 1.52.0 orjson: 3.10.5 packaging: 24.1 pydantic: 2.7.4 PyYAML: 6.0.1 requests: 2.32.3 SQLAlchemy: 2.0.35 tenacity: 8.5.0 tiktoken: 0.7.0 typing-extensions: 4.12.2
We don't have a chunk for this kind of 2-tuple right now. What's your use case?
hello, get tokens used (usage) with Azure when using streaming and structured_output
Checked other resources
Example Code
Hello, there is no way to retrieve the tokens used (usage) with Azure when using streaming and structured_output.
https://python.langchain.com/docs/how_to/structured_output/
Error Message and Stack Trace (if applicable)
No response
Description
This code disables streaming. We have to wait for the complete generation to get a response.
Expected behavior: We should be able to use streaming and retrieve the usage metadata at the end.
System Info
System Information
Package Information
Optional packages not installed
Other Dependencies