modelscope / agentscope

Start building LLM-empowered multi-agent applications in an easier way.
https://doc.agentscope.io/
Apache License 2.0
4.72k stars 294 forks source link

[Feature]: Gemini usage in agentscope through VartexAI #358

Open liuqi6776 opened 1 month ago

liuqi6776 commented 1 month ago

Vartexai is google platform based on project

For the usage, we use the code as below from vertexai.generative_models import GenerativeModel, Part import vertexai.preview.generative_models as generative_models (after run this import code need to login in google SDK) vertexai.init(project="", location="") model = GenerativeModel("gemini-1.5-pro-001",)

Can you add this Gemini usage for agentscope as the no_api_key version, for api_key is vertexai { { "config_name": "my_gemini_chat_config", "model_type": "gemini_chat",

"model_name": "{model_name}",               # Gemini Chat API中的模型名,例如:gemini-pro

"api_key": "vertexai",         

} }

DavdGao commented 1 month ago

Thanks for your attention.

Honestly, I'm a little confused about the differences between the google.generativeai and vartexai libraries since they provide similar model API serviecs. For now, we will first figure it out, and then make decisions.

@liuqi6776 Any suggestions about their differences?

liuqi6776 commented 1 month ago

@DavdGao Sure, this is some differences about their definition and implement code. 1:google.generativeai

High-Level API: This is a user-friendly Python library that offers a simplified interface for working with pre-trained generative AI models. It's designed to make it easy for developers to integrate generative AI features into their applications quickly.

Example:

from google.generativeai import generate_text

response = generate_text( model='text-davinci-003', prompt='Write a short story about a cat who goes on an adventure.' )

print(response.text)

2. vertexai.generative_models.GenerativeModel

Model Object: This is a class within the Vertex AI SDK that represents a trained generative model. It provides methods for interacting with models in a more fine-grained and flexible manner.

Customizability: vertexai.generative_models.GenerativeModel is designed for more advanced users who want more control over the model training and deployment process. You can load your own pre-trained models or train new ones.

ML Pipeline Integration: This class is integrated with the broader Vertex AI platform. This means you can take advantage of features like:

Model training: Train your own generative models with Vertex AI's managed environments. Deployment: Deploy models to serve predictions in production. Monitoring and optimization: Track and improve model performance over time. Example:

from vertexai.generative_models import GenerativeModel from vertexai.generative_models.text import TextGenerationModel

model = TextGenerationModel.create( display_name='my-text-model', model_type='text-davinci-003' )

response = model.predict( text_inputs=['Write a short story about a cat who goes on an adventure.'] )

print(response)