mirror of
https://github.com/open-webui/open-webui
synced 2025-06-16 19:31:52 +00:00
This commit introduces the initial Agent Creation Playground feature and ensures it supports all model types available in Open WebUI, not just Ollama models. Key changes include: Frontend: - Created a new Agent Creation form at `/agents/create`. - Added a link to the playground in the sidebar (admin only). - The form now fetches and displays all available models from the `/api/models` endpoint. - Updated UI to correctly handle generalized model IDs. Backend: - Modified the `Agent` model to store a generic `model_id` (foreign key to the `models` table) instead of a specific `llm_model`. - Updated API endpoints and Pydantic schemas accordingly. - Created database migrations to reflect schema changes. - Verified that the existing `/api/models` endpoint can be used to list all models for the creation form. Testing: - Added Cypress E2E tests for the agent creation form. - Tests verify that different model types can be selected and that the correct `model_id` and other agent details are submitted to the backend. This provides a foundation for you to define agents using any model integrated with your Open WebUI instance.
28 lines
1.2 KiB
Python
28 lines
1.2 KiB
Python
from sqlalchemy import Column, Integer, String, JSON, DateTime, ForeignKey
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
from datetime import datetime
|
|
|
|
Base = declarative_base()
|
|
|
|
class Agent(Base):
|
|
__tablename__ = "agent"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String, nullable=False)
|
|
role = Column(String, nullable=False)
|
|
system_message = Column(String, nullable=True)
|
|
model_id = Column(String, ForeignKey("model.id"), nullable=False) # Changed from llm_model to model_id and added ForeignKey
|
|
skills = Column(JSON, nullable=True)
|
|
user_id = Column(String, ForeignKey("user.id"), nullable=False)
|
|
timestamp = Column(DateTime, default=datetime.utcnow)
|
|
|
|
# Define the relationship to the User model if User model exists and is defined with Base
|
|
# Assuming User model is in a file named 'users.py' and User class is named 'User'
|
|
# from .users import User # Import User model
|
|
# owner = relationship("User") # Example relationship
|
|
# model = relationship("Model") # Add relationship to Model table
|
|
|
|
def __repr__(self):
|
|
return f"<Agent(id={self.id}, name='{self.name}', user_id='{self.user_id}', model_id='{self.model_id}')>"
|