Hi everyone,
I’ve fine-tuned an AI model using 10 example input/output pairs and also configured a structured output. However, when I click “Get Code” in the Python interface, I only see the structured output section—the example inputs and outputs I added are missing. Interestingly, when I switch to other languages like JavaScript or cURL, all my defined examples are visible in the exported code.
Has anyone else experienced this discrepancy? Is this behavior intended for the Python version, or is there a workaround to include the example inputs/outputs in the Python code export? FYI I am using Gemini 2.0-flash-lite
Thanks in advance for any insights or suggestions!
The code provided by ‘Get Code’:
import base64
import os
from google import genai
from google.genai import types
def generate():
client = genai.Client(
api_key=os.environ.get(“GEMINI_API_KEY”),
)
model = "gemini-2.0-flash-lite"
contents = [
types.Content(
role="user",
parts=[
types.Part.from_text(text="""INSERT_INPUT_HERE"""),
],
),
]
generate_content_config = types.GenerateContentConfig(
temperature=1,
top_p=0.95,
top_k=40,
max_output_tokens=8192,
response_mime_type="application/json",
response_schema=genai.types.Schema(
type = genai.types.Type.OBJECT,
required = ["title", "body"],
properties = {
"title": genai.types.Schema(
type = genai.types.Type.STRING,
description = "The main title of the content",
),
"body": genai.types.Schema(
type = genai.types.Type.ARRAY,
description = "An array of content sections",
items = genai.types.Schema(
type = genai.types.Type.OBJECT,
required = ["subtitle", "body_content", "metadata"],
properties = {
"subtitle": genai.types.Schema(
type = genai.types.Type.STRING,
description = "Section subtitle",
),
"body_content": genai.types.Schema(
type = genai.types.Type.OBJECT,
description = "The main content of this section - can be a string, array, or object",
properties = {
},
),
"metadata": genai.types.Schema(
type = genai.types.Type.OBJECT,
required = ["content_type", "display_hint", "priority"],
properties = {
"content_type": genai.types.Schema(
type = genai.types.Type.STRING,
description = "Type of content in this section",
enum = ["summary", "key_points", "introduction", "explanation", "strategy", "insight", "advice", "quotes", "characters"],
),
"display_hint": genai.types.Schema(
type = genai.types.Type.STRING,
description = "Visual display suggestion for this content",
enum = ["highlight", "bullet_list", "paragraph", "blockquote", "tag_cloud", "banner", "warning_banner"],
),
"priority": genai.types.Schema(
type = genai.types.Type.INTEGER,
description = "Numerical priority/order for this section",
),
},
),
},
),
),
},
),
)
for chunk in client.models.generate_content_stream(
model=model,
contents=contents,
config=generate_content_config,
):
print(chunk.text, end="")
if name == “main”:
generate()