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

Adds simple game server for gen AI #3628

Merged
merged 8 commits into from
Feb 26, 2024

Conversation

igooch
Copy link
Collaborator

@igooch igooch commented Feb 2, 2024

What type of PR is this?

/kind documentation

What this PR does / Why we need it:

Creates a simple game server that can connect to a gen AI endpoint.

Which issue(s) this PR fixes:

Special notes for your reviewer:

@github-actions github-actions bot added kind/documentation Documentation for Agones size/M labels Feb 2, 2024
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 5b448a0c-59b1-4df1-a677-ed2f145182c7

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/3628/head:pr_3628 && git checkout pr_3628
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.39.0-dev-f81ef87-amd64

@markmandel
Copy link
Member

🤔 should this be in this repo, or something like https://github.com/googleforgames/GenAI-quickstart which is more tied to Google Cloud products?

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: b54cb57f-d041-4644-a6c4-fb8c1fcd065e

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/3628/head:pr_3628 && git checkout pr_3628
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.39.0-dev-bb95bc0-amd64

@igooch igooch force-pushed the simple-genai-server branch 5 times, most recently from 252dfc0 to 2c95531 Compare February 8, 2024 18:16
@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: f7aae38e-ea2d-4b82-84ea-590749091e22

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: a7c397b1-1253-4a7f-a396-cadd60de058c

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/3628/head:pr_3628 && git checkout pr_3628
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.39.0-dev-cc755aa-amd64

examples/simple-genai-server/main.go Outdated Show resolved Hide resolved
examples/simple-genai-server/main.go Outdated Show resolved Hide resolved
examples/simple-genai-server/main.go Outdated Show resolved Hide resolved
examples/simple-genai-server/main.go Outdated Show resolved Hide resolved
examples/simple-genai-server/main.go Outdated Show resolved Hide resolved
examples/simple-genai-server/main.go Outdated Show resolved Hide resolved
examples/simple-genai-server/main.go Outdated Show resolved Hide resolved
examples/simple-genai-server/main.go Outdated Show resolved Hide resolved
examples/simple-genai-server/main.go Outdated Show resolved Hide resolved
examples/simple-genai-server/main.go Outdated Show resolved Hide resolved
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 85ce36b1-c260-4693-914d-78154de2de45

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/3628/head:pr_3628 && git checkout pr_3628
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.39.0-dev-254670d-amd64

@igooch igooch force-pushed the simple-genai-server branch 4 times, most recently from ba06ceb to 4de0a04 Compare February 12, 2024 20:09
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 556ded6e-b601-473a-a6dc-f52a40195468

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/3628/head:pr_3628 && git checkout pr_3628
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.39.0-dev-4de0a04-amd64

@igooch igooch force-pushed the simple-genai-server branch 4 times, most recently from b49fb69 to 3d573b2 Compare February 12, 2024 22:27
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: e5158145-6d98-4015-9169-db4eb9e43b3e

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/3628/head:pr_3628 && git checkout pr_3628
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.39.0-dev-3d573b2-amd64

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 9e9db44f-bc46-447a-94d8-26103c3cdda8

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/3628/head:pr_3628 && git checkout pr_3628
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.39.0-dev-ff5d917-amd64

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 0b8b0ef9-0e35-498e-aa44-038e4e1ade62

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/3628/head:pr_3628 && git checkout pr_3628
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.39.0-dev-4219ab8-amd64

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: cdb931cf-da09-44a8-81fe-d14f46b27024

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/3628/head:pr_3628 && git checkout pr_3628
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.39.0-dev-95e6039-amd64

examples/simple-genai-server/README.md Show resolved Hide resolved
examples/simple-genai-server/README.md Outdated Show resolved Hide resolved
examples/simple-genai-server/README.md Outdated Show resolved Hide resolved
examples/simple-genai-server/README.md Outdated Show resolved Hide resolved
examples/simple-genai-server/README.md Outdated Show resolved Hide resolved
examples/simple-genai-server/main.go Outdated Show resolved Hide resolved
examples/simple-genai-server/main.go Outdated Show resolved Hide resolved
examples/simple-genai-server/main.go Outdated Show resolved Hide resolved
examples/simple-genai-server/main.go Outdated Show resolved Hide resolved
examples/simple-genai-server/main.go Outdated Show resolved Hide resolved
@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 52fe37e3-3640-4a2d-a4f8-1e0e28480650

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@igooch igooch force-pushed the simple-genai-server branch 3 times, most recently from abd82d5 to db45799 Compare February 20, 2024 23:32
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: a8087197-5a65-48d6-b5ab-93438b9427b9

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/3628/head:pr_3628 && git checkout pr_3628
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.39.0-dev-db45799-amd64

Creates a flag for the GenAI endpoint.

Reuses a single http client to connect the GenAI endpoint.

Allows multiple clients to connect via TCP or UDP and takes a prompt to forward to
the GenAI endpoint and returns the response.
as the GenAI. The two clients can then chat with one another.

Also removes UDP and makes other small changes to simplify the code.
This new structure only works with the genai/chat endpoint. However, this helps to prevent the AI from quickly going into a loop of responses
@igooch igooch marked this pull request as ready for review February 22, 2024 22:03
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 5bdaea2a-3ff3-4e6f-8801-d1a81689fdf0

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/3628/head:pr_3628 && git checkout pr_3628
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.39.0-dev-26f555d-amd64

examples/simple-genai-server/README.md Outdated Show resolved Hide resolved
examples/simple-genai-server/main.go Outdated Show resolved Hide resolved
examples/simple-genai-server/main.go Outdated Show resolved Hide resolved
go autonomousChat(*prompt, genAiConn, simConn, *numChats, &wg)
wg.Wait()

log.Printf("Shutting down the Game Server.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be simpler if you just put these lines into the autonomousChat function when you hit the base case:

	if numChats <= 0 {
		log.Printf("Shutting down the Game Server.")
		shutdownErr := s.Shutdown()
		if shutdownErr != nil {
			log.Printf("Could not shutdown")
		}
		return
	}

I also think that having the wait group here means that the <-sigCtx.Done() line below never gets executed until after the autonomous chats complete. So an interrupt wouldn't be caught.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed up the code to pass through the sigCtx to the autonomousChat.

We get an error "error":"http: Server closed" after the request to shutdown, but it looks like that's coming from the SDK Server httpEndpoint.

{"gsKey":"default/gen-ai-server-auto","message":"SDK server shutdown requested, waiting for game server shutdown","severity":"info","source":"*sdkserver.SDKServer","state":"RequestReady","time":"2024-02-23T23:25:18.158333903Z"}
{"message":"Shutting down SDK server","severity":"info","source":"main","time":"2024-02-23T23:25:18.196158733Z"}
{"error":"http: Server closed","message":"http server closed","severity":"info","source":"main","time":"2024-02-23T23:25:18.196415148Z"}
{"gsKey":"default/gen-ai-server-auto","message":"...shutting down workers","queue":"agones.dev.default.gen-ai-server-auto","severity":"info","source":"*sdkserver.SDKServer","time":"2024-02-23T23:25:18.196206956Z"}
{"error":"http: Server closed","gsKey":"default/gen-ai-server-auto","message":"Health check: http server closed","severity":"error","source":"*sdkserver.SDKServer","time":"2024-02-23T23:25:18.196492334Z"}

@roberthbailey
Copy link
Member

Just the one last comment on the new code that you added. Then this should be ready to merge!

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: a4fca4b8-a585-4ff0-9ee7-b4f814892eb4

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/3628/head:pr_3628 && git checkout pr_3628
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.39.0-dev-2e9cad7-amd64

@roberthbailey roberthbailey self-assigned this Feb 23, 2024
Passes through the NewSigKillContext to the autonomous chat to allow for
more graceful shutdown of the Game Server in the case of an interrupt.
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 1da4fa9e-f6b3-4119-b94e-276acfdd0552

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/3628/head:pr_3628 && git checkout pr_3628
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.39.0-dev-2ca9096-amd64

@roberthbailey roberthbailey merged commit 76548a2 into googleforgames:main Feb 26, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants