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

feat: Add support for code execution in ChatGoogleGenerativeAI #564

Merged
merged 1 commit into from
Oct 8, 2024

Conversation

davidmigloz
Copy link
Owner

@davidmigloz davidmigloz commented Oct 8, 2024

ChatGoogleGenerativeAI supports code execution, just set enableCodeExecution to true in the options.

final chatModel = ChatGoogleGenerativeAI(
  apiKey: apiKey,
  defaultOptions: ChatGoogleGenerativeAIOptions(
    model: 'gemini-1.5-flash',
    enableCodeExecution: true,
  ),
);
final res = await chatModel.invoke(
  PromptValue.string(
    'Calculate the fibonacci sequence up to 10 terms. '
        'Return only the last term without explanations.',
  ),
);

final text = res.output.content;
print(text); // 34

final executableCode = res.metadata['executable_code'] as String;
print(executableCode);

final codeExecutionResult = res.metadata['code_execution_result'] as Map<String, dynamic>;
print(codeExecutionResult);

@davidmigloz davidmigloz self-assigned this Oct 8, 2024
@davidmigloz davidmigloz added t:enhancement New feature or request c:chat-models Chat models. p:langchain_google langchain_google package. labels Oct 8, 2024
@davidmigloz davidmigloz added this to the v0.8.0 milestone Oct 8, 2024
@davidmigloz davidmigloz merged commit 020bc09 into main Oct 8, 2024
3 checks passed
@davidmigloz davidmigloz deleted the code-execution branch October 8, 2024 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c:chat-models Chat models. p:langchain_google langchain_google package. t:enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant