langchain-ai / langchain-google

MIT License
117 stars 149 forks source link

langchain-google-genai: Usage Metadata is missing #573

Closed holiholiholiholi closed 1 week ago

holiholiholiholi commented 3 weeks ago

The information in the response field 'usage_metadata' is missing. Is it possible to add this info to the Generation object as what langchain-vertexai does?

so example in langchain_google_vertexai.llm

                if self._is_gemini_model:
                    usage_metadata = res.to_dict().get("usage_metadata")
                else:
                    usage_metadata = res.raw_prediction_response.metadata
                generations.append(
                    [
                        self._candidate_to_generation(r, usage_metadata=usage_metadata)
                        for r in res.candidates
                    ]
                )
lkuligin commented 3 weeks ago

yes, sure. Would you be open to work on that?

holiholiholiholi commented 3 weeks ago

ja :) @lkuligin

yes, sure. Would you be open to work on that?