Skip to content

Commit

Permalink
add endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-XT committed Jan 7, 2025
1 parent eea0342 commit 9d4560d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
38 changes: 37 additions & 1 deletion agixt/endpoints/Agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}` ?
Expand Down
7 changes: 4 additions & 3 deletions agixt/graphqlendpoints/Schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 9d4560d

Please sign in to comment.