Skip to content

lorensr/ai-group-chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI group chat with:

  • a GraphQL federated subscription for getting messages to the client
  • a durable function for easily maintaining chat state and reliably coordinating with OpenAI

Built for GraphQL Summit 2024. See Summit talk and slides, and more info in this post and this talk.

Contents:

Code structure

Turborepo monorepo.

Apps

  • apps/web - Next.js client (subscription code: components/group-chat.tsx)
  • apps/router - Apollo router
  • apps/users-service - subgraph that resolves the User entity (see index.ts)
  • apps/messages-service - subgraph that handles Subscriptions and proxies Queries and Mutations to the durable function (index.ts)
  • apps/worker - runs the durable functions

Packages

  • packages/common - types generated from messages schema and supergraph schema
  • packages/durable-functions - the groupChat durable function (index.ts)
  • packages/activities - normal functions called by the durable function, including AI SDK code that talks to OpenAI (index.ts)
  • packages/ui - UI components
  • packages/eslint-config
  • packages/typescript-config

Set up

brew install temporal
curl -sSL https://rover.apollo.dev/nix/latest | sh
git clone https://github.com/lorensr/ai-group-chat.git
cd ai-group-chat
npm i

Create a .env file at the project root with these values filled in:

APOLLO_KEY=
APOLLO_GRAPH_REF=
OPENAI_API_KEY=

The Apollo info must be from a free trial Enterprise account (until Apollo releases federated subscriptions to GraphOS Cloud).

Run

temporal server start-dev
npm run dev

About

AI group chat with a GraphQL federated subscription and durable function

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •