phidatahq / phidata

Build AI Agents with memory, knowledge, tools and reasoning. Chat with them using a beautiful Agent UI.
https://docs.phidata.com
Mozilla Public License 2.0
13.86k stars 1.95k forks source link

Integrate fine-tuned Gemini model with Phidata Agents #1294

Open Lancelottery opened 5 days ago

Lancelottery commented 5 days ago

Hi, I would like to integrate my fine-tuned gemini model from vertex ai studio with Phi Agents. I have the fine-tuned model endpoints ready. According to the documentation, https://docs.phidata.com/models/google_ai_studio, it seems like it only supports pre-trained Gemini? How do I integrate them?

aliyevom commented 5 days ago
  1. Set Authentication:

    
    export GOOGLE_API_KEY=your-google-api-key
  2. Modify Agent Code:

    from phi.agent import Agent
    from phi.model.google import Gemini
    
    agent = Agent(
       model=Gemini(id="your-fine-tuned-model-id"),  # Replace with your model ID
       show_tool_calls=True,
       markdown=True,
       api_key="your-google-api-key"
    )
    
    agent.print_response("Test response from fine-tuned Gemini model.")

Ensure that you replace "your-fine-tuned-model-id" with the actual model ID from Vertex AI Studio.

For more customization options, you can configure generation_config with additional settings.


agent = Agent(
    model=Gemini(
        id="your-fine-tuned-model-id",
        generation_config={"temperature": 0.7, "max_tokens": 150},  # Example settings
        api_key="your-google-api-key"
    ),
    show_tool_calls=True,
    markdown=True,
)
ysolanky commented 4 days ago

Hey @Lancelottery !

Currently we only support Gemini via Google ai studio for the Agent Class. We are working on extending support for Vertex ai as well.

Though, with our fully functioning but older Assistant class you can use Gemini via Vertex ai. Here is a cookbook to get you started: https://github.com/phidatahq/phidata/tree/main/cookbook/assistants/llms/vertexai

Please let me know if you have any further questions