कोड लागू करें

कोड एक्ज़ीक्यूशन एक ऐसा टूल है जिसकी मदद से मॉडल, Python कोड जनरेट और रन कर सकता है. मॉडल, कोड एक्ज़ीक्यूशन के नतीजों से बार-बार सीख सकता है. ऐसा तब तक होता है, जब तक वह फ़ाइनल आउटपुट तक नहीं पहुंच जाता.

कोड एक्ज़ीक्यूशन का इस्तेमाल करके, ऐसी सुविधाएं बनाई जा सकती हैं जो कोड पर आधारित तर्क का इस्तेमाल करती हैं और टेक्स्ट आउटपुट जनरेट करती हैं. उदाहरण के लिए, समीकरणों को हल करने या टेक्स्ट को प्रोसेस करने के लिए, कोड एक्ज़ीक्यूशन का इस्तेमाल किया जा सकता है. कोड एक्ज़ीक्यूशन एनवायरमेंट में शामिल लाइब्रेरी का इस्तेमाल करके, ज़्यादा खास टास्क भी किए जा सकते हैं.

मॉडल को दिए गए सभी टूल की तरह ही, मॉडल यह तय करता है कि कोड एक्ज़ीक्यूशन की सुविधा का इस्तेमाल कब करना है.

कोड लागू करने के तरीके पर जाएं

कोड एक्ज़ीक्यूशन और फ़ंक्शन कॉलिंग के बीच तुलना

कोड एक्ज़ीक्यूशन और फ़ंक्शन कॉलिंग, एक जैसी सुविधाएँ हैं. आम तौर पर, अगर मॉडल आपके इस्तेमाल के उदाहरण को हैंडल कर सकता है, तो आपको कोड एक्ज़ीक्यूशन का इस्तेमाल करना चाहिए. कोड एक्ज़ीक्यूशन की सुविधा को इस्तेमाल करना भी आसान है, क्योंकि आपको बस इसे चालू करना होता है.

कोड एक्ज़ीक्यूशन और फ़ंक्शन कॉलिंग के बीच कुछ और अंतर यहां दिए गए हैं:

कोड एक्ज़ीक्यूशन फ़ंक्शन कॉलिंग
अगर आपको मॉडल से Python कोड लिखवाना और चलाना है, तो कोड एक्ज़ीक्यूशन की सुविधा का इस्तेमाल करें. इससे आपको कोड का नतीजा भी मिलेगा. अगर आपके पास पहले से ही ऐसे फ़ंक्शन हैं जिन्हें आपको स्थानीय तौर पर चलाना है, तो फ़ंक्शन कॉलिंग का इस्तेमाल करें.
कोड एक्ज़ीक्यूशन की सुविधा से, मॉडल को एपीआई बैकएंड में कोड चलाने की अनुमति मिलती है. यह कोड, एक तय और अलग एनवायरमेंट में चलाया जाता है. फ़ंक्शन कॉलिंग की सुविधा की मदद से, मॉडल के अनुरोध किए गए फ़ंक्शन को अपनी पसंद के किसी भी एनवायरमेंट में चलाया जा सकता है.
कोड एक्ज़ीक्यूशन की सुविधा, एक ही अनुरोध में समस्या हल कर देती है. हालाँकि, चैट की सुविधा के साथ कोड एक्ज़ीक्यूशन का इस्तेमाल किया जा सकता है, लेकिन यह ज़रूरी नहीं है. फ़ंक्शन कॉलिंग के लिए, हर फ़ंक्शन कॉल से आउटपुट वापस भेजने के लिए एक और अनुरोध करना ज़रूरी है. इसलिए, आपको चैट की सुविधा का इस्तेमाल करना होगा.

इस्तेमाल किए जा सकने वाले मॉडल

  • gemini-4-argon
  • gemini-3.8-flash (और पुराने gemini-3.7-flash, gemini-3.6-flash, और gemini-3.5-flash)
  • gemini-3.5-flash-lite (और gemini-3.1-flash-lite का पुराना वर्शन)

gemini-3.1-pro-preview और सामान्य इस्तेमाल के लिए उपलब्ध Gemini 2.5 मॉडल (जो अब काम नहीं करते) में भी यह सुविधा काम करती है.

कोड एक्ज़ीक्यूशन का इस्तेमाल करना

कोड एक्ज़ीक्यूशन का इस्तेमाल, सिर्फ़ टेक्स्ट वाले और मल्टीमोडल इनपुट, दोनों के साथ किया जा सकता है. हालांकि, जवाब हमेशा सिर्फ़ टेक्स्ट या कोड के तौर पर मिलेगा.

शुरू करने से पहले

इस पेज पर, Gemini API की सेवा देने वाली कंपनी के हिसाब से कॉन्टेंट और कोड देखने के लिए, सेवा देने वाली कंपनी के नाम पर क्लिक करें.

अगर आपने अब तक ऐसा नहीं किया है, तो शुरुआती निर्देश पढ़ें. इसमें Firebase प्रोजेक्ट सेट अप करने, अपने ऐप्लिकेशन को Firebase से कनेक्ट करने, और SDK टूल जोड़ने का तरीका बताया गया है. साथ ही, इसमें अपनी पसंद के Gemini API प्रोवाइडर के लिए बैकएंड सेवा को शुरू करने और GenerativeModel इंस्टेंस बनाने का तरीका भी बताया गया है.

अपने प्रॉम्प्ट को टेस्ट करने और उनमें बदलाव करने के लिए, हमारा सुझाव है कि आप Google AI Studio का इस्तेमाल करें.

कोड एक्ज़ीक्यूशन की सुविधा चालू करना

इस सैंपल को आज़माने से पहले, इस गाइड का शुरू करने से पहले सेक्शन पूरा करें, ताकि आप अपना प्रोजेक्ट और ऐप्लिकेशन सेट अप कर सकें.
इस सेक्शन में, आपको Gemini APIसेवा देने वाली कंपनी के लिए एक बटन पर भी क्लिक करना होगा, ताकि आपको इस पेज पर सेवा देने वाली कंपनी के हिसाब से कॉन्टेंट दिखे.

GenerativeModel इंस्टेंस बनाते समय, CodeExecution को एक टूल के तौर पर उपलब्ध कराएं, ताकि मॉडल इसका इस्तेमाल करके जवाब जनरेट कर सके. इससे मॉडल को Python कोड जनरेट करने और चलाने की अनुमति मिलती है.

Swift


import FirebaseAILogic

// Initialize the Gemini Developer API backend service.
let ai = FirebaseAI.firebaseAI(backend: .googleAI())

// Create a `GenerativeModel` instance with a model that supports your use case
let model = ai.generativeModel(
  modelName: "GEMINI_MODEL_NAME",
  // Provide code execution as a tool that the model can use to generate its response.
  tools: [.codeExecution()]
)

let prompt = """
What is the sum of the first 50 prime numbers?
Generate and run code for the calculation, and make sure you get all 50.
"""

let response = try await model.generateContent(prompt)

guard let candidate = response.candidates.first else {
  print("No candidates in response.")
  return
}
for part in candidate.content.parts {
  if let textPart = part as? TextPart {
    print("Text = \(textPart.text)")
  } else if let executableCode = part as? ExecutableCodePart {
    print("Code = \(executableCode.code), Language = \(executableCode.language)")
  } else if let executionResult = part as? CodeExecutionResultPart {
    print("Outcome = \(executionResult.outcome), Result = \(executionResult.output ?? "no output")")
  }
}

Kotlin


// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports your use case.
val model = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(
    modelName = "GEMINI_MODEL_NAME",
    // Provide code execution as a tool that the model can use to generate its response.
    tools = listOf(Tool.codeExecution())
)

val prompt =  "What is the sum of the first 50 prime numbers? " +
        "Generate and run code for the calculation, and make sure you get all 50."

val response = model.generateContent(prompt)

response.candidates.first().content.parts.forEach {
    if(it is TextPart) {
        println("Text = ${it.text}")
    }
    if(it is ExecutableCodePart) {
        println("Code = ${it.code}, Language = ${it.language}")
    }
    if(it is CodeExecutionResultPart) {
       println("Outcome = ${it.outcome}, Result = ${it.output}")
    }
}

Java


// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports your use case.
GenerativeModel ai = FirebaseAI.getInstance(GenerativeBackend.googleAI())
                .generativeModel("GEMINI_MODEL_NAME",
                        null,
                        null,
                        // Provide code execution as a tool that the model can use to generate its response.
                        List.of(Tool.codeExecution()));

// Use the GenerativeModelFutures Java compatibility layer which offers
// support for ListenableFuture and Publisher APIs
GenerativeModelFutures model = GenerativeModelFutures.from(ai);

String text = "What is the sum of the first 50 prime numbers? " +
        "Generate and run code for the calculation, and make sure you get all 50.";

Content prompt = new Content.Builder()
    .addText(text)
    .build();

ListenableFuture response = model.generateContent(prompt);

Futures.addCallback(response, new FutureCallback() {
   @Override
public void onSuccess(GenerateContentResponse response)   {
    // Access the first candidate's content parts
    List parts = response.getCandidates().get(0).getContent().getParts();
    for (Part part : parts) {
        if (part instanceof TextPart) {
            TextPart textPart = (TextPart) part;
            System.out.println("Text = " + textPart.getText());
        } else if (part instanceof ExecutableCodePart) {
            ExecutableCodePart codePart = (ExecutableCodePart) part;
            System.out.println("Code = " + codePart.getCode() + ", Language = " + codePart.getLanguage());
        } else if (part instanceof CodeExecutionResultPart) {
            CodeExecutionResultPart resultPart = (CodeExecutionResultPart) part;
            System.out.println("Outcome = " + resultPart.getOutcome() + ", Result = " + resultPart.getOutput());
        }
    }
}

    @Override
    public void onFailure(Throwable t) {
        t.printStackTrace();
    }
}, executor);

Web


import { initializeApp } from "firebase/app";
import { getAI, getGenerativeModel, GoogleAIBackend } from "firebase/ai";

// TODO(developer): Replace the following with your app's Firebase configuration
// See: https://firebase.google.com/docs/web/learn-more#config-object
const firebaseConfig = {
  // ...
};

// Initialize FirebaseApp
const firebaseApp = initializeApp(firebaseConfig);

// Initialize the Gemini Developer API backend service.
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });

// Create a `GenerativeModel` instance with a model that supports your use case.
const model = getGenerativeModel(
  ai,
  {
    model: "GEMINI_MODEL_NAME",
    // Provide code execution as a tool that the model can use to generate its response.
    tools: [{ codeExecution: {} }]
  }
);

const prompt =  "What is the sum of the first 50 prime numbers? " +
        "Generate and run code for the calculation, and make sure you get all 50."

const result = await model.generateContent(prompt);
const response = await result.response;

const parts = response.candidates?.[0].content.parts;

if (parts) {
  parts.forEach((part) => {
    if (part.type === "text") {
      console.log(`Text: ${part.text}`);
    } else if (part.type === "executableCode") {
      console.log(
        `Code: ${part.executableCode.code}, Language: ${part.executableCode.language}`
      );
    } else if (part.type === "codeExecutionResult") {
      console.log(
        `Outcome: ${part.codeExecutionResult.outcome}, Result: ${part.codeExecutionResult.output}`
      );
    }
  });
}

Dart


import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_ai/firebase_ai.dart';
import 'firebase_options.dart';

// Initialize FirebaseApp
await Firebase.initializeApp(
  options: DefaultFirebaseOptions.currentPlatform,
);

// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports your use case.
final model = FirebaseAI.googleAI().generativeModel(
  model: 'GEMINI_MODEL_NAME',
  // Provide code execution as a tool that the model can use to generate its response.
  tools: [
    Tool.codeExecution(),
  ],
);

const prompt = 'What is the sum of the first 50 prime numbers? '
    'Generate and run code for the calculation, and make sure you get all 50.';

final response = await model.generateContent([Content.text(prompt)]);

final buffer = StringBuffer();
    for (final part in response.candidates.first.content.parts) {
      if (part is TextPart) {
        buffer.writeln(part.text);
      } else if (part is ExecutableCodePart) {
        buffer.writeln('Executable Code:');
        buffer.writeln('Language: ${part.language}');
        buffer.writeln('Code:');
        buffer.writeln(part.code);
      } else if (part is CodeExecutionResultPart) {
        buffer.writeln('Code Execution Result:');
        buffer.writeln('Outcome: ${part.outcome}');
        buffer.writeln('Output:');
        buffer.writeln(part.output);
      }
    }

Unity


using Firebase;
using Firebase.AI;

// Initialize the Gemini Developer API backend service.
var ai = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI());

// Create a `GenerativeModel` instance with a model that supports your use case.
var model = ai.GetGenerativeModel(
  modelName: "GEMINI_MODEL_NAME",
  // Provide code execution as a tool that the model can use to generate its response.
  tools: new Tool[] { new Tool(new CodeExecution()) }
);

var prompt = "What is the sum of the first 50 prime numbers? " +
        "Generate and run code for the calculation, and make sure you get all 50.";

var response = await model.GenerateContentAsync(prompt);

foreach (var part in response.Candidates.First().Content.Parts) {
  if (part is ModelContent.TextPart tp) {
    UnityEngine.Debug.Log($"Text = {tp.Text}");
  } else if (part is ModelContent.ExecutableCodePart esp) {
    UnityEngine.Debug.Log($"Code = {esp.Code}, Language = {esp.Language}");
  } else if (part is ModelContent.CodeExecutionResultPart cerp) {
    UnityEngine.Debug.Log($"Outcome = {cerp.Outcome}, Output = {cerp.Output}");
  }
}

अपने इस्तेमाल के उदाहरण और ऐप्लिकेशन के लिए, मॉडल चुनने का तरीका जानें.भी चुनी जा सकती है.

चैट में कोड एक्ज़ीक्यूशन की सुविधा का इस्तेमाल करना

चैट के दौरान भी कोड एक्ज़ीक्यूशन की सुविधा का इस्तेमाल किया जा सकता है:

Swift


import FirebaseAILogic

// Initialize the Gemini Developer API backend service.
let ai = FirebaseAI.firebaseAI(backend: .googleAI())

// Create a `GenerativeModel` instance with a model that supports your use case
let model = ai.generativeModel(
  modelName: "GEMINI_MODEL_NAME",
  // Provide code execution as a tool that the model can use to generate its response.
  tools: [.codeExecution()]
)

let prompt = """
What is the sum of the first 50 prime numbers?
Generate and run code for the calculation, and make sure you get all 50.
"""
let chat = model.startChat()

let response = try await chat.sendMessage(prompt)

guard let candidate = response.candidates.first else {
  print("No candidates in response.")
  return
}
for part in candidate.content.parts {
  if let textPart = part as? TextPart {
    print("Text = \(textPart.text)")
  } else if let executableCode = part as? ExecutableCodePart {
    print("Code = \(executableCode.code), Language = \(executableCode.language)")
  } else if let executionResult = part as? CodeExecutionResultPart {
    print("Outcome = \(executionResult.outcome), Result = \(executionResult.output ?? "no output")")
  }
}

Kotlin


// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports your use case.
val model = Firebase.ai(backend = GenerativeBackend.googleAI()).generativeModel(
    modelName = "GEMINI_MODEL_NAME",
    // Provide code execution as a tool that the model can use to generate its response.
    tools = listOf(Tool.codeExecution())
)

val prompt =  "What is the sum of the first 50 prime numbers? " +
        "Generate and run code for the calculation, and make sure you get all 50."
val chat = model.startChat()
val response = chat.sendMessage(prompt)

response.candidates.first().content.parts.forEach {
    if(it is TextPart) {
        println("Text = ${it.text}")
    }
    if(it is ExecutableCodePart) {
        println("Code = ${it.code}, Language = ${it.language}")
    }
    if(it is CodeExecutionResultPart) {
       println("Outcome = ${it.outcome}, Result = ${it.output}")
    }
}

Java


// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports your use case.
GenerativeModel ai = FirebaseAI.getInstance(GenerativeBackend.googleAI())
                .generativeModel("GEMINI_MODEL_NAME",
                        null,
                        null,
                        // Provide code execution as a tool that the model can use to generate its response.
                        List.of(Tool.codeExecution()));

// Use the GenerativeModelFutures Java compatibility layer which offers
// support for ListenableFuture and Publisher APIs
GenerativeModelFutures model = GenerativeModelFutures.from(ai);
String text = "What is the sum of the first 50 prime numbers? " +
        "Generate and run code for the calculation, and make sure you get all 50.";

Content prompt = new Content.Builder()
    .addText(text)
    .build();

ChatFutures chat = model.startChat();
ListenableFuture response = chat.sendMessage(prompt);

Futures.addCallback(response, new FutureCallback() {
   @Override
public void onSuccess(GenerateContentResponse response)   {
    // Access the first candidate's content parts
    List parts = response.getCandidates().get(0).getContent().getParts();
    for (Part part : parts) {
        if (part instanceof TextPart) {
            TextPart textPart = (TextPart) part;
            System.out.println("Text = " + textPart.getText());
        } else if (part instanceof ExecutableCodePart) {
            ExecutableCodePart codePart = (ExecutableCodePart) part;
            System.out.println("Code = " + codePart.getCode() + ", Language = " + codePart.getLanguage());
        } else if (part instanceof CodeExecutionResultPart) {
            CodeExecutionResultPart resultPart = (CodeExecutionResultPart) part;
            System.out.println("Outcome = " + resultPart.getOutcome() + ", Result = " + resultPart.getOutput());
        }
    }
}

    @Override
    public void onFailure(Throwable t) {
        t.printStackTrace();
    }
}, executor);

Web


import { initializeApp } from "firebase/app";
import { getAI, getGenerativeModel, GoogleAIBackend } from "firebase/ai";

// TODO(developer): Replace the following with your app's Firebase configuration
// See: https://firebase.google.com/docs/web/learn-more#config-object
const firebaseConfig = {
  // ...
};

// Initialize FirebaseApp
const firebaseApp = initializeApp(firebaseConfig);

// Initialize the Gemini Developer API backend service.
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });

// Create a `GenerativeModel` instance with a model that supports your use case.
const model = getGenerativeModel(
  ai,
  {
    model: "GEMINI_MODEL_NAME",
    // Provide code execution as a tool that the model can use to generate its response.
    tools: [{ codeExecution: {} }]
  }
);

const prompt =  "What is the sum of the first 50 prime numbers? " +
        "Generate and run code for the calculation, and make sure you get all 50."
const chat = model.startChat()
const result = await chat.sendMessage(prompt);

const parts = result.response.candidates?.[0].content.parts;

if (parts) {
  parts.forEach((part) => {
    if (part.type === "text") {
      console.log(`Text: ${part.text}`);
    } else if (part.type === "executableCode") {
      console.log(
        `Code: ${part.executableCode.code}, Language: ${part.executableCode.language}`
      );
    } else if (part.type === "codeExecutionResult") {
      console.log(
        `Outcome: ${part.codeExecutionResult.outcome}, Result: ${part.codeExecutionResult.output}`
      );
    }
  });
}

Dart


import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_ai/firebase_ai.dart';
import 'firebase_options.dart';

// Initialize FirebaseApp
await Firebase.initializeApp(
  options: DefaultFirebaseOptions.currentPlatform,
);

// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports your use case.
final model = FirebaseAI.googleAI().generativeModel(
  model: 'GEMINI_MODEL_NAME',
  // Provide code execution as a tool that the model can use to generate its response.
  tools: [
    Tool.codeExecution(),
  ],
);

final codeExecutionChat = await model.startChat();

const prompt = 'What is the sum of the first 50 prime numbers? '
    'Generate and run code for the calculation, and make sure you get all 50.';
final response = await codeExecutionChat.sendMessage(Content.text(prompt));

final buffer = StringBuffer();
    for (final part in response.candidates.first.content.parts) {
      if (part is TextPart) {
        buffer.writeln(part.text);
      } else if (part is ExecutableCodePart) {
        buffer.writeln('Executable Code:');
        buffer.writeln('Language: ${part.language}');
        buffer.writeln('Code:');
        buffer.writeln(part.code);
      } else if (part is CodeExecutionResultPart) {
        buffer.writeln('Code Execution Result:');
        buffer.writeln('Outcome: ${part.outcome}');
        buffer.writeln('Output:');
        buffer.writeln(part.output);
      }
    }

Unity


using Firebase;
using Firebase.AI;

// Initialize the Gemini Developer API backend service.
var ai = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI());

// Create a `GenerativeModel` instance with a model that supports your use case.
var model = ai.GetGenerativeModel(
  modelName: "GEMINI_MODEL_NAME",
  // Provide code execution as a tool that the model can use to generate its response.
  tools: new Tool[] { new Tool(new CodeExecution()) }
);

var prompt = "What is the sum of the first 50 prime numbers? " +
        "Generate and run code for the calculation, and make sure you get all 50.";
var chat = model.StartChat();
var response = await chat.SendMessageAsync(prompt);

foreach (var part in response.Candidates.First().Content.Parts) {
  if (part is ModelContent.TextPart tp) {
    UnityEngine.Debug.Log($"Text = {tp.Text}");
  } else if (part is ModelContent.ExecutableCodePart esp) {
    UnityEngine.Debug.Log($"Code = {esp.Code}, Language = {esp.Language}");
  } else if (part is ModelContent.CodeExecutionResultPart cerp) {
    UnityEngine.Debug.Log($"Outcome = {cerp.Outcome}, Output = {cerp.Output}");
  }
}

अपने इस्तेमाल के उदाहरण और ऐप्लिकेशन के लिए, मॉडल चुनने का तरीका जानें.भी चुनी जा सकती है.

कीमत

कोड एक्ज़ीक्यूशन की सुविधा चालू करने और इसे मॉडल के लिए टूल के तौर पर उपलब्ध कराने के लिए, कोई अतिरिक्त शुल्क नहीं लिया जाता. अगर मॉडल, कोड एक्ज़ीक्यूशन की सुविधा का इस्तेमाल करता है, तो आपसे इनपुट और आउटपुट टोकन की मौजूदा दर के हिसाब से शुल्क लिया जाएगा. यह शुल्क, इस्तेमाल किए जा रहे Gemini मॉडल के आधार पर तय किया जाएगा.

इस डायग्राम में, कोड एक्ज़ीक्यूशन के लिए बिलिंग मॉडल दिखाया गया है:

इस डायग्राम में दिखाया गया है कि जब कोई मॉडल कोड एक्ज़ीक्यूशन का इस्तेमाल करता है, तो टोकन के लिए बिलिंग कैसे की जाती है. 

यहां बताया गया है कि जब कोई मॉडल कोड एक्ज़ीक्यूशन की सुविधा का इस्तेमाल करता है, तब टोकन के लिए बिल कैसे जनरेट होता है:

  • ओरिजनल प्रॉम्प्ट के लिए, सिर्फ़ एक बार बिल भेजा जाता है. इसके टोकन को इंटरमीडिएट टोकन के तौर पर लेबल किया जाता है. इनका बिल इनपुट टोकन के तौर पर भेजा जाता है.

  • जनरेट किए गए कोड और एक्ज़ीक्यूट किए गए कोड के नतीजे के लिए, इस तरह से बिलिंग की जाती है:

    • कोड एक्ज़ीक्यूशन के दौरान इस्तेमाल किए जाने पर, इन्हें इंटरमीडिएट टोकन के तौर पर लेबल किया जाता है. इनका शुल्क, इनपुट टोकन के तौर पर लिया जाता है.

    • जब इन्हें फ़ाइनल रिस्पॉन्स में शामिल किया जाता है, तो इन्हें आउटपुट टोकन के तौर पर बिल किया जाता है.

  • फ़ाइनल जवाब में मौजूद फ़ाइनल समरी के लिए, आउटपुट टोकन के तौर पर बिल किया जाता है.

Gemini API, एपीआई से मिली जानकारी में इंटरमीडिएट टोकन की संख्या शामिल करता है. इससे आपको पता चलता है कि शुरुआती प्रॉम्प्ट के अलावा, इनपुट टोकन के लिए आपसे शुल्क क्यों लिया जा रहा है.

ध्यान दें कि जनरेट किए गए कोड में टेक्स्ट और मल्टीमोडल आउटपुट, दोनों शामिल हो सकते हैं. जैसे, इमेज.

सीमाएं और सबसे सही तरीके

  • यह मॉडल सिर्फ़ Python कोड जनरेट और एक्ज़ीक्यूट कर सकता है. यह मीडिया फ़ाइलों जैसे अन्य आर्टफ़ैक्ट नहीं दिखा सकता.

  • कोड एक्ज़ीक्यूशन की सुविधा, टाइम आउट होने से पहले ज़्यादा से ज़्यादा 30 सेकंड तक चल सकती है.

  • कुछ मामलों में, कोड एक्ज़ीक्यूशन की सुविधा चालू करने से, मॉडल आउटपुट के अन्य क्षेत्रों में रिग्रेशन हो सकता है. उदाहरण के लिए, कहानी लिखना.

  • कोड एक्ज़ीक्यूशन टूल, इनपुट/आउटपुट के तौर पर फ़ाइल यूआरआई का इस्तेमाल नहीं करता. हालांकि, कोड एक्ज़ीक्यूशन टूल, इनलाइन बाइट के तौर पर फ़ाइल इनपुट और ग्राफ़ आउटपुट के साथ काम करता है. इनपुट और आउटपुट की इन सुविधाओं का इस्तेमाल करके, CSV और टेक्स्ट फ़ाइलें अपलोड की जा सकती हैं. साथ ही, फ़ाइलों के बारे में सवाल पूछे जा सकते हैं. इसके अलावा, कोड एक्ज़ीक्यूशन के नतीजे के तौर पर Matplotlib ग्राफ़ जनरेट किए जा सकते हैं. इनलाइन बाइट के लिए, इन एमआईएमई टाइप का इस्तेमाल किया जा सकता है: .cpp, .csv, .java, .jpeg, .js, .png, .py, .ts, और .xml.

इस्तेमाल की जा सकने वाली लाइब्रेरी

कोड एक्ज़ीक्यूशन एनवायरमेंट में ये लाइब्रेरी शामिल होती हैं. अपनी लाइब्रेरी इंस्टॉल नहीं की जा सकतीं.


Firebase AI Logic के साथ अपने अनुभव के बारे में सुझाव/राय देना या शिकायत करना