-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Enhance vertexai integration (safety settings, authentication...) #3067
Conversation
54aff5b
to
7e83c59
Compare
The changes from the commit fix errors with gemini message format in chats are to fix an issue I have encountered when running the following code: import os
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
import autogen
from autogen import Agent, AssistantAgent, ConversableAgent, UserProxyAgent
import google.auth
from google.auth import impersonated_credentials
credentials, project = google.auth.default()
target_scopes = [
'https://www.googleapis.com/auth/cloud-platform']
target_credentials = impersonated_credentials.Credentials(
source_credentials=credentials,
target_principal='autogen@autogen-with-gemini.iam.gserviceaccount.com',
target_scopes = target_scopes,
lifetime=500)
llm_config = {
"config_list": [{"model": "gemini-1.5-pro", "api_type": "google", "credentials": target_credentials, "project": "autogen-with-gemini"}],
}
financial_tasks = [
"""What are the current stock prices of NVDA and TESLA, and how is the performance over the past month in terms of percentage change?""",
"""Investigate possible reasons of the stock performance.""",
"""Plot a graph comparing the stock prices over the past month.""",
]
writing_tasks = ["""Develop an engaging blog post using any information provided."""]
financial_assistant = autogen.AssistantAgent(
name="Financial_assistant",
llm_config=llm_config,
)
research_assistant = autogen.AssistantAgent(
name="Researcher",
llm_config=llm_config,
)
writer = autogen.AssistantAgent(
name="writer",
llm_config=llm_config,
system_message="""
You are a professional writer, known for
your insightful and engaging articles.
You transform complex concepts into compelling narratives.
Reply "TERMINATE" in the end when everything is done.
""",
)
user = autogen.UserProxyAgent(
name="User",
human_input_mode="NEVER",
is_termination_msg=lambda x: x.get("content", "") and x.get("content", "").rstrip().endswith("TERMINATE"),
code_execution_config={
"last_n_messages": 1,
"work_dir": "tasks",
"use_docker": False,
}, # Please set use_docker=True if docker is available to run the generated code. Using docker is safer than running the generated code directly.
)
chat_results = user.initiate_chats(
[
{
"recipient": financial_assistant,
"message": financial_tasks[0],
"clear_history": True,
"silent": False,
"summary_method": "last_msg",
},
{
"recipient": research_assistant,
"message": financial_tasks[1],
"summary_method": "reflection_with_llm",
},
{
"recipient": writer,
"message": writing_tasks[0],
"carryover": "I want to include a figure or a table of data in the blogpost.",
},
]
) Details abbout the issue, which the commit fixes:
|
7e83c59
to
ee6890f
Compare
a741515
to
8c30ad3
Compare
Could you make the PR from a branch in the upstream repo so that the openai CI could be run? Thanks. |
Sure, I will do it :) |
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. 🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request. |
…ting converion for vertexai
…ting converion for vertexai
The new PR from the upstream repo is #3086 |
Why are these changes needed?
credentials
objects in thellm_config
for more flexibility:Adding safety settings conversion to VertexAI format from the OAI_CONFIG_LIST
Support
system_message
, which are calledsystem_instructions
with GeminiConsolidate message handling in
send_message
to use the officially supportedPartsType
for thecontent
argumentUse
project
instead ofproject_id
argument for theGeminiClient
to follow the same naming convention as thevertexai.init()
method doesRelated issue number
Relates to #2387
Checks