Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to_dict method when encoding JSON #799

Merged
merged 1 commit into from
Jan 15, 2025
Merged

Try to_dict method when encoding JSON #799

merged 1 commit into from
Jan 15, 2025

Conversation

alexmojaki
Copy link
Contributor

With this code:

import vertexai
from vertexai.generative_models import GenerativeModel

import logfire

logfire.configure()
vertexai.init()
model = GenerativeModel('gemini-1.5-flash-002')
chat = model.start_chat()
response = chat.send_message('What is 2+2?')
logfire.info('response', response=response)

this PR changes the attributes from:

{
  "response": "candidates {\n  content {\n    role: \"model\"\n    parts {\n      text: \"2 + 2 = 4\\n\"\n    }\n  }\n  finish_reason: STOP\n  avg_logprobs: -5.3347812354331836e-06\n}\nusage_metadata {\n  prompt_token_count: 7\n  candidates_token_count: 8\n  total_token_count: 15\n}\nmodel_version: \"gemini-1.5-flash-002\"\n"
}

to

{
  "response": {
    "candidates": [
      {
        "content": {
          "role": "model",
          "parts": [
            {
              "text": "2 + 2 = 4\n"
            }
          ]
        },
        "finish_reason": "STOP",
        "avg_logprobs": -0.000005319886440702248
      }
    ],
    "usage_metadata": {
      "prompt_token_count": 7,
      "candidates_token_count": 8,
      "total_token_count": 15
    },
    "model_version": "gemini-1.5-flash-002"
  }
}

@alexmojaki alexmojaki requested a review from Kludex January 14, 2025 18:12
Copy link

codecov bot commented Jan 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (6ab0661) to head (42df0bc).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #799   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          138       138           
  Lines        11036     11040    +4     
  Branches      1565      1565           
=========================================
+ Hits         11036     11040    +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alexmojaki alexmojaki merged commit c2806ef into main Jan 15, 2025
15 checks passed
@alexmojaki alexmojaki deleted the alex/to-dict branch January 15, 2025 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants