diff --git a/agixt/endpoints/Agent.py b/agixt/endpoints/Agent.py index fd89954fd51b..a1a84a737c5f 100644 --- a/agixt/endpoints/Agent.py +++ b/agixt/endpoints/Agent.py @@ -686,7 +686,43 @@ async def think( ) -from Providers import get_provider_options +from Providers import get_providers_with_details, get_provider_options + + +# Get connected agent providers +@app.get( + "/v1/agent/{agent_id}/providers", + tags=["Agent"], + dependencies=[Depends(verify_api_key)], + summary="Get agent providers", + description="Retrieves the list of providers connected to a specific agent.", + response_model=Dict[str, str], +) +async def get_providers( + agent_id: str, + user=Depends(verify_api_key), + authorization: str = Header(None), +) -> Dict[str, str]: + ApiClient = get_api_client(authorization=authorization) + agent = Agent(agent_name=agent_id, user=user, ApiClient=ApiClient) + agent_settings = agent.AGENT_CONFIG["settings"] + providers = get_providers_with_details() + new_providers = {} + # Check each provider against agent settings for a match to see if the key is defined in agent settings and is not empty + # If it is, set connected = True, else connected = False + for provider in providers: + provider_name = list(provider.keys())[0] + provider_details = list(provider.values())[0] + provider_settings = provider_details["settings"] + connected = False + for key in provider_settings: + if key in agent_settings and agent_settings[key] != "": + connected = True + new_providers[provider_name] = { + "connected": connected, + **provider_details, + } + return {"providers": new_providers} # `DEL /v1/agent/{agent_id}/provider/{provider_name}` ? diff --git a/agixt/graphqlendpoints/Schema.py b/agixt/graphqlendpoints/Schema.py index 7b4211fc6d17..1ce31a5f0c3d 100644 --- a/agixt/graphqlendpoints/Schema.py +++ b/agixt/graphqlendpoints/Schema.py @@ -7,7 +7,8 @@ # from graphqlendpoints.Extensions import schema as extensions_schema # from graphqlendpoints.Memories import schema as memories_schema from graphqlendpoints.Conversations import schema as conversations_schema -from graphqlendpoints.Prompts import schema as prompts_schema + +# from graphqlendpoints.Prompts import schema as prompts_schema from graphqlendpoints.Providers import schema as providers_schema @@ -20,7 +21,7 @@ class Query( # extensions_schema.Query, # memories_schema.Query, conversations_schema.Query, - prompts_schema.Query, + # prompts_schema.Query, providers_schema.Query, ): pass @@ -35,7 +36,7 @@ class Mutation( # extensions_schema.Mutation, # memories_schema.Mutation, conversations_schema.Mutation, - prompts_schema.Mutation, + # prompts_schema.Mutation, providers_schema.Mutation, ): pass