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

Add frontend for the http (not websocket) chat endpoint #19

Merged
merged 3 commits into from
Jan 8, 2025

Conversation

ChristopherChudzicki
Copy link
Contributor

What are the relevant tickets?

Description (What does it do?)

Adds a very minimal frontend intended for local development and possibly demoing that hits the chat API with component from https://mitodl.github.io/smoot-design/?path=/docs/smoot-design-aichat--docs

Additionally, this changes the SSE (server-sent events) endpoint to use raw text streaming. SSE proved somewhat inconvenient—. Browsers have an interface EventStream to parse the responses, but it only works with GET requests not POST. If we need a more structured format in the future, the format described here https://sdk.vercel.ai/docs/ai-sdk-ui/stream-protocol#data-stream-protocol might be good.

How can this be tested?

With the repo set up (you should only need OPENAI_API_KEY), docker compose up and

  1. Visit http://ai.open.odl.local:8003/
  2. Try chatting.
  3. Verify that memory works... Try asking "What was my last message to you?"

Comment on lines -131 to +130
await self.send_event(event=chunk, more_body=True)
await self.send_chunk(chunk)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Locally, this iteration takes many seconds, but the body text doesn't seem to actually be sent until it finishes. It is sent incrementally if an artificial await asyncio.sleep(0.1) is inserted.

So, something doesn't seem right here, but it behaves this way on main, too, so not related to the change from SSE to regular text.

Comment on lines 82 to 117
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./frontend-demo
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
with:
node-version: "^22"
cache: yarn
cache-dependency-path: yarn.lock

- name: Install dependencies
run: yarn install --immutable

- name: Format
run: yarn run fmt-check

- name: Lints
run: yarn run lint-check

# do build before typecheck. See https://github.com/vercel/next.js/issues/53959#issuecomment-1735563224
- name: Build
run: yarn build
env:
NODE_ENV: production
NEXT_PUBLIC_MITOL_API_BASE_URL: "http://ai.test.local:8003"

- name: Typecheck
run: yarn typecheck

- name: Tests
run: yarn test
env:
CODECOV: true
NODE_ENV: test

Check warning

Code scanning / CodeQL

Workflow does not contain permissions

Actions Job or Workflow does not set permissions
.github/workflows/ci.yml Fixed Show fixed Hide fixed
Comment on lines 88 to 94
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4
with:
node-version: "^22"
cache: yarn
cache-dependency-path: yarn.lock

- name: Install dependencies

Check notice

Code scanning / CodeQL

Unversioned Immutable Action

The workflow is using an eligible immutable action ([actions/setup-node](1)) without semantic versioning
.github/workflows/ci.yml Fixed Show fixed Hide fixed
.github/workflows/ci.yml Fixed Show fixed Hide fixed
@ChristopherChudzicki ChristopherChudzicki changed the title Add frontend for the http (not websoket) chat endpoint Add frontend for the http (not websocket) chat endpoint Jan 7, 2025
FROM ghcr.io/berriai/litellm:main-latest
FROM ghcr.io/berriai/litellm:main-stable
Copy link
Contributor Author

@ChristopherChudzicki ChristopherChudzicki Jan 7, 2025

Choose a reason for hiding this comment

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

main-latest was giving an error, moving to stable fixed it.

Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime 
create failed: runc create failed: unable to start container process: exec: "docker/prod_entrypoint.sh": stat 
docker/prod_entrypoint.sh: no such file or directory: unknown

@abeglova abeglova self-assigned this Jan 8, 2025
Copy link

@abeglova abeglova left a comment

Choose a reason for hiding this comment

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

lgtm

@ChristopherChudzicki ChristopherChudzicki merged commit 77d2c14 into main Jan 8, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants