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 backend controller and client for Gen AI #57944

Merged
merged 23 commits into from Apr 13, 2024

Conversation

fisher-alice
Copy link
Contributor

@fisher-alice fisher-alice commented Apr 10, 2024

This PR adds the aichat_controller which will make requests to Sagemaker when the API is available and the corresponding client file aichatCompletionApi which makes a call to the controller. This will be used when a user submits a chat message in the Aichat workspace.

The controller receives:

  • messages including the system prompt, retrieval contexts, past user messages and assistant responses
  • the temperature from savedAiCustomizations
  • chatContext that includes the newest user message text, userId, currentLevelId, scriptId, and channelId.

The controller sends back a dummy assistant response for now. Screenshot from dev console after adding print statements in aichatCompletionApi.ts and aichatRedux of response.

Screenshot 2024-04-11 at 3 27 13 PM

Response displayed in workspace:
Screenshot 2024-04-11 at 4 00 38 PM

Links

jira

Testing story

Tested locally using /allthethings levels.

Screenshots from Network Tab:

Screenshot 2024-04-11 at 3 22 53 PM

Screenshot 2024-04-11 at 3 23 21 PM

Screenshot 2024-04-11 at 3 23 28 PM

Deployment strategy

Follow-up work

Privacy

Security

Caching

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

return render(status: :ok, json: {status: filter_result.type, flagged_content: filter_result.content}) if filter_result
inputs = params[:inputs]
temperature = params[:temperature]
# TODO: Format input to send to Sagemaker.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still waiting clarification on how to format. Using this ref as a reference for now.

@fisher-alice fisher-alice marked this pull request as ready for review April 11, 2024 20:29
Copy link
Contributor

@bencodeorg bencodeorg left a comment

Choose a reason for hiding this comment

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

Sorry, kind of got comment happy :) Mostly small things / me trying to understand this stuff better!

One overall q -- is there any value in maintaining the existing API that can actually talk to an AI (ie, openai) in the short term, rather than cutting over to this new version that isn't actually hooked up? I was wondering if Dan and co. might find that useful for taking screenshots/etc.

apps/src/aichat/views/presentation/PresentationView.tsx Outdated Show resolved Hide resolved
dashboard/app/controllers/aichat_controller.rb Outdated Show resolved Hide resolved
apps/src/aichat/aichatCompletionApi.ts Outdated Show resolved Hide resolved
apps/src/aichat/redux/aichatRedux.ts Show resolved Hide resolved
apps/src/aichat/redux/aichatRedux.ts Show resolved Hide resolved
apps/src/aichat/redux/aichatRedux.ts Show resolved Hide resolved
apps/src/aichat/redux/aichatRedux.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@sanchitmalhotra126 sanchitmalhotra126 left a comment

Choose a reason for hiding this comment

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

Nice, this is coming together well! A few comments but looks solid overall

apps/src/aichat/views/UserChatMessageEditor.tsx Outdated Show resolved Hide resolved
apps/src/aichat/views/UserChatMessageEditor.tsx Outdated Show resolved Hide resolved
apps/src/aichat/views/UserChatMessageEditor.tsx Outdated Show resolved Hide resolved
apps/src/aichat/views/UserChatMessageEditor.tsx Outdated Show resolved Hide resolved
@fisher-alice
Copy link
Contributor Author

Sorry, kind of got comment happy :) Mostly small things / me trying to understand this stuff better!

One overall q -- is there any value in maintaining the existing API that can actually talk to an AI (ie, openai) in the short term, rather than cutting over to this new version that isn't actually hooked up? I was wondering if Dan and co. might find that useful for taking screenshots/etc.

Thanks Ben - this is all great feedback! Posted your overall question in this Slack thread and the response from Dan and Sanchit is that we should go ahead and proceed with getting aichat connect to new endpoint. Thanks!

Copy link
Contributor

@bencodeorg bencodeorg left a comment

Choose a reason for hiding this comment

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

Looks like a good checkpoint to me!

apps/src/util/sharedVoices.js Outdated Show resolved Hide resolved
apps/src/aichat/aichatCompletionApi.ts Show resolved Hide resolved
apps/src/aichat/aichatCompletionApi.ts Outdated Show resolved Hide resolved
apps/src/aichat/types.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@sanchitmalhotra126 sanchitmalhotra126 left a comment

Choose a reason for hiding this comment

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

Looks good!

apps/src/aichat/aichatCompletionApi.ts Outdated Show resolved Hide resolved
apps/src/aichat/types.ts Outdated Show resolved Hide resolved
apps/src/aichat/redux/aichatRedux.ts Outdated Show resolved Hide resolved
@fisher-alice fisher-alice merged commit 7ee3d1b into staging Apr 13, 2024
2 checks passed
@fisher-alice fisher-alice deleted the alice/add-genai-controller branch April 13, 2024 15:10
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.

None yet

3 participants