Skip to content

Commit

Permalink
Tweak: Setting up the Game Server (#3717)
Browse files Browse the repository at this point in the history
* Tweak: Setting up the Game Server

* Review changes

---------

Co-authored-by: Zach Loafman <[email protected]>
Co-authored-by: igooch <[email protected]>
  • Loading branch information
3 people committed Mar 21, 2024
1 parent 11d83f2 commit 4348d92
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions site/content/en/docs/Examples/simple-genai-gameserver.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,25 @@ on that cluster, otherwise install Agones into your GenAI inference server clust

## Setting up the Game Server

To manually interact with `GEN_AI_ENDPOINT` via netcat, modify the
[gameserver_manualchat.yaml](https://github.com/googleforgames/agones/blob/main/examples/simple-genai-server/gameserver_manualchat.yaml) `GenAiEndpoint` value to your inference server's endpoint. Optionally, include the `GEN_AI_CONTEXT` in your `gameserver_manualchat.yaml` that will
include the context with each chat (post request) that you make to the GenAI endpoint.

If you want to have two clients "chat" to each other, modify the
[gameserver_autochat.yaml](https://github.com/googleforgames/agones/blob/main/examples/simple-genai-server/gameserver_autochat.yaml) `GEN_AI_ENDPOINT` value to your inference
server's endpoint. Also modify the `SIM_ENDPOINT` value to your inference server's endpoint.
Alternatively you can create a basic http server that accepts requests in the structure noted in the
above section, and returns a predetermined set of responses for the chat. The `GEN_AI_CONTEXT` is sent
to the `GEN_AI_ENDPOINT` with each request, and the `SIM_CONTEXT` is sent to the `SIM_ENDPOINT` with
each request as part of the GenAIRequest structure. The default values for `GEN_AI_CONTEXT` and
`SIM_CONTEXT` are empty strings. The `PROMPT` is the first sent to prompt send to the GenAI endpoint
to start the chat. The default values for the prompt is an empty string. `NUM_CHATS` is the number of
requests made to the `SIM_ENDPOINT` and `GEN_AI_ENDPOINT`. The default value for is `NUM_CHATS` is `1`.

If you want to set up the chat with the npc-chat-api from the [Google for Games GenAI](https://github.com/googleforgames/GenAI-quickstart/tree/main/genai/api/npc_chat_api)
modify the [gameserver_npcchat.yaml](https://github.com/googleforgames/agones/blob/main/examples/simple-genai-server/gameserver_npcchat.yaml). Set either the
`GEN_AI_ENDPOINT` or `SIM_ENDPOINT` to the NPC service `"http://genai-api.genai.svc/genai/npc_chat"`.
Set whichever endpoint is pointing to the NPC service, either the `GEN_AI_NPC` or `SIM_NPC`,
to be `"true"`. The `NPCRequest` to the NPC endpoint only sends the message (prompt), so any
additional context outside of the prompt is ignored. `FROM_ID` is the entity sending messages to NPC,
and `TO_ID` is the entity receiving the message (the NPC ID).
To manually interact with `GenAiEndpoint` via netcat, change the `GEN_AI_ENDPOINT` value in the
[gameserver_manualchat.yaml](https://github.com/googleforgames/agones/blob/main/examples/simple-genai-server/gameserver_manualchat.yaml) file
to your inference server’s endpoint. Optionally, include the `GEN_AI_CONTEXT` in the same file that will include the context with
each chat (post request) that you make to the GenAI endpoint.

To make two clients "chat" to each other, change the `GEN_AI_ENDPOINT` and `SIM_ENDPOINT` values in the [gameserver_autochat.yaml](https://github.com/googleforgames/agones/blob/main/examples/simple-genai-server/gameserver_autochat.yaml) file
to your inference server's address. You could also create a basic http server that receives requests in the structure noted in the above section,
and returns a predetermined set of responses for the chat. When sending requests, `GEN_AI_CONTEXT` is sent to the `GEN_AI_ENDPOINT`
and `SIM_CONTEXT` is sent to the `SIM_ENDPOINT` as part of the GenAIRequest structure. The default values for `GEN_AI_CONTEXT` and `SIM_CONTEXT`
are empty strings. The conversation starts with a `PROMPT` that is sent to the GenAI endpoint, which is also an empty string by default.
`NUM_CHATS` determines how many times messages are sent back and forth, with a default value of 1.
It's important to note that the chat between two clients is a rolling conversation, meaning that after completing a conversation of length set by `NUM_CHATS`, a new conversation starts. This cycle continues until the game server is deleted using the `kubectl delete` command.

If you want to set up the chat with the npc-chat-api from the [Google for Games GenAI](https://github.com/googleforgames/GenAI-quickstart/tree/main/genai/api/npc_chat_api),
update the [gameserver_npcchat.yaml](https://github.com/googleforgames/agones/blob/main/examples/simple-genai-server/gameserver_npcchat.yaml) file.
Choose between `GEN_AI_ENDPOINT` or `SIM_ENDPOINT` and set it to `http://genai-api.genai.svc/genai/npc_chat` for the NPC service.
Mark either `GEN_AI_NPC` or `SIM_NPC` as "true" to indicate it's connected to the NPC service. The `NPCRequest` to the NPC endpoint only sends
the message (prompt), so any additional context outside of the prompt is ignored. FROM_ID is the entity sending messages to NPC, and
TO_ID is the entity receiving the message (the NPC ID). A new conversation begins either when it reaches the length `NUM_CHATS` or when it reaches the `STOP_PHRASE`, whichever happens first.
```
type NPCRequest struct {
Msg string `json:"message,omitempty"`
Expand Down

0 comments on commit 4348d92

Please sign in to comment.