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

Option to use Azure search with the chatbot #1330

Merged
merged 37 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
63ed8d3
WIP
nygrenh Sep 25, 2024
4f55d27
Make precommit hooks lighter and introduce bin/git-run-precommit-checks
nygrenh Sep 25, 2024
9cd78de
Sqlx prepare
nygrenh Sep 25, 2024
af47fb7
WIP
nygrenh Sep 25, 2024
85bafbb
WIP
nygrenh Sep 26, 2024
e66f712
WIP
nygrenh Sep 26, 2024
61a6e91
WIP
nygrenh Sep 26, 2024
26e0ae3
WIP
nygrenh Sep 27, 2024
d7ce5ef
WIP
nygrenh Sep 27, 2024
e491e5d
Chatbot ui refactoring
nygrenh Sep 30, 2024
95118f2
Refactoring
nygrenh Sep 30, 2024
2c4b3d4
Fix button location
nygrenh Sep 30, 2024
4bb3bf1
Refactoring
nygrenh Sep 30, 2024
52c67a8
WIP
nygrenh Sep 30, 2024
75d932e
WIP
nygrenh Oct 3, 2024
50f98c9
Move chatbot into its own crate
nygrenh Oct 4, 2024
84f9c4c
Make errors more flexible
nygrenh Oct 4, 2024
79cb4cb
Fix
nygrenh Oct 4, 2024
45a5565
WIP azure blob storage
nygrenh Oct 4, 2024
ec5a97e
WIP
nygrenh Oct 4, 2024
3856f45
Implement delteting old pages
nygrenh Oct 9, 2024
a93d729
Refactoring
nygrenh Oct 9, 2024
8a5ed92
WIP
nygrenh Oct 10, 2024
e6c4e15
WIP
nygrenh Oct 14, 2024
b86e8e6
Resolving problems
nygrenh Oct 14, 2024
a91060d
Logging improvements
nygrenh Oct 14, 2024
030452a
Fixes
nygrenh Oct 15, 2024
c5d2188
Fixes
nygrenh Oct 15, 2024
afd40ac
WIP using the search index
nygrenh Oct 16, 2024
ed3ed89
Refactoring
nygrenh Oct 16, 2024
f508c5a
Refactoring
nygrenh Oct 16, 2024
c611c50
Make token estimation take sent message into account
nygrenh Oct 16, 2024
2a311ce
Fix request guard being dropped before the stream is ready and use co…
nygrenh Oct 16, 2024
0d1eb90
Add configuration, and finalizing
nygrenh Oct 17, 2024
32d288b
Add deployment
nygrenh Oct 17, 2024
d6c6e25
Fix
nygrenh Oct 17, 2024
4a50df4
Don't crash if azure not configured
nygrenh Oct 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module.exports = {
// Runs when you run bin/git-run-branch-ready-checks.
// These checks are slower and more likely to fail than the precommit checks.
// See lint-staged.precommit.config.js for precommit checks.
module.exports = {
"*.{js,jsx,ts,tsx}": ["eslint --cache --fix", "stylelint --fix"],
"services/example-exercise/src/**/*.{js,jsx,ts,tsx}": () =>
"npx tsc -p services/example-exercise/ --noEmit",
Expand Down
13 changes: 13 additions & 0 deletions .husky/lint-staged.precommit.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Runs on precommit.
// Focuses on tests that are fast to run don't fail often. For other checks, see bin/git-run-branch-ready-checks and lint-staged.branch-ready.config.js
module.exports = {
"*.{js,jsx,ts,tsx}": ["eslint --cache --fix", "stylelint --fix"],
"*.{md,json,scss,css}": "prettier --write",
"*.rs": () => [
"cargo fmt --manifest-path services/headless-lms/Cargo.toml --all -- --files-with-diff",
],
"system-tests/src/**/*.{js,jsx,ts,tsx}": () => [
`./bin/check-no-test-only-in-system-tests`,
],
"shared-module/packages/common/src/locales/**/*.json": () => ["./bin/translations-sort"],
}
12 changes: 1 addition & 11 deletions .husky/post-commit
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
#!/bin/sh
LAST_TIME_PRECOMMIT_SUCCESSFUL=".husky/_/saved-hashes/last-time-precommit-succesful"
# Read the the saved UNIX timestamp from the file and check if the timestamp is recent
if [ -f "$LAST_TIME_PRECOMMIT_SUCCESSFUL" ] && [ $(($(date +%s) - $(cat "$LAST_TIME_PRECOMMIT_SUCCESSFUL"))) -lt 3000 ]; then
# The precommit checks were successful recently so no need to print the warning
rm "$LAST_TIME_PRECOMMIT_SUCCESSFUL" 2> /dev/null || true
exit 0
fi

rm "$LAST_TIME_PRECOMMIT_SUCCESSFUL" 2> /dev/null || true

echo "ℹ️ Detected you used git commit with --no-verify. This may be fine if you don't want to wait for the checks to complete, but you'll need to ensure all the skipped checks pass before you create a pull request or your branch is merged."
echo ""
echo "👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇"
echo ""
printf "\033[1;31m⚠️ ONCE YOU'RE READY WITH THE BRANCH, RUN bin/git-run-precommit-checks AND MAKE SURE EVERYTHING PASSES ⚠️\033[0m\n"
printf "\033[1;31m⚠️ ONCE YOU'RE READY WITH THE BRANCH, RUN bin/git-run-branch-ready-checks AND MAKE SURE EVERYTHING PASSES ⚠️\033[0m\n"
echo ""
echo "👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆"
echo ""
Expand Down
6 changes: 1 addition & 5 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@
# Makes the check faster, and the database does not have to be running to commit
export SQLX_OFFLINE=1

npx lint-staged -c ./.husky/lint-staged.config.js

# Save the last time this was succesfully ran so that we can detect in post-commit if this script was skipped with --no-verify
LAST_TIME_PRECOMMIT_SUCCESSFUL=".husky/_/saved-hashes/last-time-precommit-succesful"
date +%s > "$LAST_TIME_PRECOMMIT_SUCCESSFUL"
npx lint-staged -c ./.husky/lint-staged.precommit.config.js
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Secret Project 331

## Development environment setup

Read [Development.md](https://github.com/rage/secret-project-331/blob/master/docs/Development.md) on how to setup using Windows or Linux.
Expand All @@ -12,7 +13,7 @@ bin/seed
## Code style:

```bash
npm run eslint
bin/git-run-branch-ready-checks
```

## Documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -euo pipefail
source "$(dirname "$0")/.common"

echo -e "${BLUE}Runs precommit checks manually by comparing what has changed in this branch. You have to use this command if you have used git commit with --no-verify at some point.${RESET_EVERYTHING}"
echo -e "${BLUE}Checks code for common issues. This script should be used when you're done with branch, and you want to do finishing touches to it..${RESET_EVERYTHING}"
echo -e "${BLUE}It might be a good idea to also run ${BOLD}bin/git-merge-origin-master${RESET_EVERYTHING}"
echo ""

Expand All @@ -15,6 +15,6 @@ run_command cd "$RELATIVE_PATH"
CURRENT_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
MERGE_BASE=$(git merge-base origin/master "$CURRENT_BRANCH_NAME")

run_command npx lint-staged -c ./.husky/lint-staged.config.js --diff "$MERGE_BASE" "$@"
run_command npx lint-staged -c ./.husky/lint-staged.branch-ready.config.js --diff "$MERGE_BASE" "$@"

echo -e "${GREEN}✅ All precommit checks passed.${RESET_EVERYTHING}"
54 changes: 54 additions & 0 deletions kubernetes/base/headless-lms/chatbot-syncer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: chatbot-syncer
labels:
app: chatbot-syncer
deploymentType: with-init-container
needs-db: "true"
spec:
replicas: 1
selector:
matchLabels:
app: chatbot-syncer
template:
metadata:
annotations:
linkerd.io/inject: enabled
labels:
app: chatbot-syncer
spec:
containers:
- name: chatbot-syncer
image: headless-lms
command: ["bin/run", "chatbot-syncer"]
resources:
requests:
memory: 100Mi
cpu: 20m
limits:
memory: 300Mi
cpu: 200m
envFrom:
- secretRef:
name: headless-lms-secrets
initContainers:
- name: headless-lms-wait-for-db
image: headless-lms
command:
- bash
- "-c"
- |
echo Waiting for postgres to be available
timeout 120 ./wait-for-db.sh
./wait-for-db-migrations.sh
resources:
requests:
memory: 100Mi
cpu: 20m
limits:
memory: 300Mi
cpu: 200m
envFrom:
- secretRef:
name: headless-lms-secrets
1 change: 1 addition & 0 deletions kubernetes/base/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ resources:
- headless-lms/regrader.yml
- headless-lms/peer-review-updater.yml
- headless-lms/sync-tmc-users.yml
- headless-lms/chatbot-syncer.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { css, keyframes } from "@emotion/css"
import { useQuery } from "@tanstack/react-query"
import { useEffect, useState } from "react"
import React, { useEffect, useState } from "react"

import ChatbotDialogBody from "./ChatbotDialogBody"
import ChatbotDialogHeader from "./ChatbotDialogHeader"
Expand Down Expand Up @@ -39,6 +39,8 @@ const ChatbotDialog: React.FC<ChatbotDialogProps> = (props) => {
const { dialogOpen, chatbotConfigurationId } = props
const [shouldRender, setShouldRender] = useState(dialogOpen)

const [error, setError] = useState<Error | null>(null)

const currentConversationInfoQuery = useQuery({
queryKey: ["currentConversationInfo", chatbotConfigurationId],
queryFn: () => getChatbotCurrentConversationInfo(chatbotConfigurationId),
Expand Down Expand Up @@ -83,7 +85,12 @@ const ChatbotDialog: React.FC<ChatbotDialogProps> = (props) => {
onAnimationEnd={handleAnimationEnd}
>
<ChatbotDialogHeader {...props} currentConversationInfo={currentConversationInfoQuery} />
<ChatbotDialogBody {...props} currentConversationInfo={currentConversationInfoQuery} />
<ChatbotDialogBody
{...props}
currentConversationInfo={currentConversationInfoQuery}
error={error}
setError={setError}
/>
</div>
)
}
Expand Down
Loading
Loading