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

Add endpoint for getting all models #214

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion apps/api/src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
)
from .improver import PromptType, improve_prompt
from .interfaces import db
from .models import Profile
from .models import Profile, LLMModel
from .routers import agents, api_key_types, api_keys
from .routers import auth as auth_router
from .routers import (
Expand Down Expand Up @@ -114,3 +114,8 @@ def auto_build_crew(general_task: str) -> str:
@app.get("/me")
def get_profile_from_header(current_user=Depends(get_current_user)) -> Profile:
return current_user


@app.get("/models")
def get_models() -> list[LLMModel]:
return db.get_models()
7 changes: 7 additions & 0 deletions apps/api/src/interfaces/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
Tool,
ToolInsertRequest,
ToolUpdateRequest,
LLMModel
)
from src.models.tiers import TierGetRequest

Expand Down Expand Up @@ -869,6 +870,12 @@ def delete_profile(profile_id: UUID) -> Profile:
return Profile(**response.data[0])


def get_models() -> list[LLMModel]:
supabase: Client = create_client(url, key)
response = supabase.table("models").select("*").execute()
return [LLMModel(**data) for data in response.data]


if __name__ == "__main__":
from src.models import Session

Expand Down
2 changes: 2 additions & 0 deletions apps/api/src/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
AgentGetRequest,
AgentInsertRequest,
AgentUpdateModel,
LLMModel,
)
from .api_key import (
APIKey,
Expand Down Expand Up @@ -108,4 +109,5 @@
"BillingInsertRequest",
"BillingUpdateRequest",
"ValidCrew",
"LLMModel",
]
Loading