Skip to content

Commit

Permalink
Release ai-proxy v1.2.0 (#1755)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljguarino authored Jan 16, 2025
1 parent af414cf commit 1000695
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 27 deletions.
3 changes: 2 additions & 1 deletion assets/src/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6819,7 +6819,8 @@ export type RootQueryTypeClusterProvidersArgs = {


export type RootQueryTypeClusterRegistrationArgs = {
id: Scalars['ID']['input'];
id?: InputMaybe<Scalars['ID']['input']>;
machineId?: InputMaybe<Scalars['String']['input']>;
};


Expand Down
22 changes: 2 additions & 20 deletions charts/ai-proxy/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
apiVersion: v2
name: ai-proxy
description: A Helm chart for ai-proxy

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v1.1.0"
version: 0.2.1
appVersion: "v1.2.0"
3 changes: 2 additions & 1 deletion lib/console/deployments/clusters.ex
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ defmodule Console.Deployments.Clusters do

def get_cluster_usage!(id), do: Repo.get!(ClusterUsage, id) |> Repo.preload([:cluster])

def get_cluster_registration(id), do: Repo.get!(ClusterRegistration, id)
def get_cluster_registration!(id), do: Repo.get!(ClusterRegistration, id)
def get_registration_by_machine_id!(id), do: Repo.get_by!(ClusterRegistration, machine_id: id)

def get_runtime_service(id) do
Console.Repo.get(RuntimeService, id)
Expand Down
2 changes: 1 addition & 1 deletion lib/console/deployments/init.ex
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ defmodule Console.Deployments.Init do
Map.put(attrs, :ai, %{
provider: :openai,
enabled: true,
openai: %{base_url: "http://ai-proxy.ai-proxy:8000/openai"}
openai: %{base_url: "http://ai-proxy.ai-proxy:8000/openai/v1"}
})
_ -> attrs
end
Expand Down
3 changes: 2 additions & 1 deletion lib/console/graphql/deployments/cluster.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,8 @@ defmodule Console.GraphQl.Deployments.Cluster do

field :cluster_registration, :cluster_registration do
middleware Authenticated
arg :id, non_null(:id)
arg :id, :id
arg :machine_id, :string

resolve &Deployments.resolve_cluster_registration/2
end
Expand Down
6 changes: 5 additions & 1 deletion lib/console/graphql/resolvers/deployments/cluster.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ defmodule Console.GraphQl.Resolvers.Deployments.Cluster do
|> allow(user, :read)
end

def resolve_cluster_registration(%{machine_id: id}, %{context: %{current_user: user}}) do
Clusters.get_registration_by_machine_id!(id)
|> allow(user, :read)
end
def resolve_cluster_registration(%{id: id}, %{context: %{current_user: user}}) do
Clusters.get_cluster_registration(id)
Clusters.get_cluster_registration!(id)
|> allow(user, :read)
end

Expand Down
2 changes: 1 addition & 1 deletion schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ type RootQueryType {

clusterUsage(id: ID!): ClusterUsage

clusterRegistration(id: ID!): ClusterRegistration
clusterRegistration(id: ID, machineId: String): ClusterRegistration

clusterRegistrations(after: String, first: Int, before: String, last: Int): ClusterRegistrationConnection

Expand Down
2 changes: 1 addition & 1 deletion test/console/deployments/init_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ defmodule Console.Deployments.InitTest do

assert res.settings.ai.enabled
assert res.settings.ai.provider == :openai
assert res.settings.ai.openai.base_url == "http://ai-proxy.ai-proxy:8000/openai"
assert res.settings.ai.openai.base_url == "http://ai-proxy.ai-proxy:8000/openai/v1"
end
end
end
13 changes: 13 additions & 0 deletions test/console/graphql/queries/deployments/cluster_queries_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,19 @@ defmodule Console.GraphQl.Deployments.ClusterQueriesTest do

assert found["id"] == reg.id
end

test "bootstrap token creators can read by machine id" do
user = bootstrap_user()
reg = insert(:cluster_registration, creator: user)

{:ok, %{data: %{"clusterRegistration" => found}}} = run_query("""
query Reg($machineId: String!) {
clusterRegistration(machineId: $machineId) { id }
}
""", %{"machineId" => reg.machine_id}, %{current_user: user})

assert found["id"] == reg.id
end
end

describe "clusterRegistrations" do
Expand Down

0 comments on commit 1000695

Please sign in to comment.