From 5ca128975826533aa6c0f63835135bbaef56c2bd Mon Sep 17 00:00:00 2001 From: Kumaran Rajendhiran Date: Mon, 1 Jul 2024 14:01:14 +0530 Subject: [PATCH 1/7] Fix retrieving bing api key in websurfer (#470) * Fix retrieving bing api key in websurfer * Include missing together model --- fastagency/models/agents/web_surfer.py | 11 ++++++++++- fastagency/models/llms/together.py | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/fastagency/models/agents/web_surfer.py b/fastagency/models/agents/web_surfer.py index 40cb5edd..ef01fc13 100644 --- a/fastagency/models/agents/web_surfer.py +++ b/fastagency/models/agents/web_surfer.py @@ -63,9 +63,18 @@ async def create_autogen( my_model.summarizer_llm.uuid, user_id ) + bing_api_key = None + if my_model.bing_api_key: + bing_api_key_model = await my_model.bing_api_key.get_data_model().from_db( + my_model.bing_api_key.uuid + ) + bing_api_key = await bing_api_key_model.create_autogen( + my_model.bing_api_key.uuid, user_id + ) + browser_config = { "viewport_size": my_model.viewport_size, - "bing_api_key": my_model.bing_api_key, + "bing_api_key": bing_api_key, } agent_name = my_model.name diff --git a/fastagency/models/llms/together.py b/fastagency/models/llms/together.py index 517c43b0..f777de67 100644 --- a/fastagency/models/llms/together.py +++ b/fastagency/models/llms/together.py @@ -49,6 +49,7 @@ "Platypus2 Instruct (70B)": "garage-bAInd/Platypus2-70B-instruct", "Gemma Instruct (2B)": "google/gemma-2b-it", "Gemma Instruct (7B)": "google/gemma-7b-it", + "Gemma-2 Instruct (9B)": "google/gemma-2-9b-it", "Vicuna v1.5 (13B)": "lmsys/vicuna-13b-v1.5", "Vicuna v1.5 (7B)": "lmsys/vicuna-7b-v1.5", "Reserved - DBRX Instruct": "medaltv/dbrx-instruct", From 7cfd526a673111a8f050c16788a27331dd2a7d3c Mon Sep 17 00:00:00 2001 From: Harish Mohan Raj Date: Mon, 1 Jul 2024 16:14:55 +0530 Subject: [PATCH 2/7] Support for multiline chat query (#471) --- app/package-lock.json | 54 +++++++++++ app/package.json | 1 + app/src/client/components/ChatForm.tsx | 49 ++++++++-- .../client/components/SelectTeamToChat.tsx | 12 ++- app/src/client/tests/ChatForm.test.tsx | 91 +++++++++++++++++++ 5 files changed, 197 insertions(+), 10 deletions(-) diff --git a/app/package-lock.json b/app/package-lock.json index 51eb4d4a..29675839 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -27,6 +27,7 @@ "react-apexcharts": "^1.4.1", "react-hot-toast": "^2.4.1", "react-icons": "4.11.0", + "react-textarea-autosize": "^8.5.3", "stripe": "11.15.0", "tailwind-merge": "^2.2.1", "uuid": "^9.0.1", @@ -9514,6 +9515,22 @@ "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, + "node_modules/react-textarea-autosize": { + "version": "8.5.3", + "resolved": "https://registry.npmjs.org/react-textarea-autosize/-/react-textarea-autosize-8.5.3.tgz", + "integrity": "sha512-XT1024o2pqCuZSuBt9FwHlaDeNtVrtCXu0Rnz88t1jUGheCLa3PhjE1GH8Ctm2axEtvdCl5SUHYschyQ0L5QHQ==", + "dependencies": { + "@babel/runtime": "^7.20.13", + "use-composed-ref": "^1.3.0", + "use-latest": "^1.2.1" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/read-cache": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", @@ -10908,6 +10925,43 @@ "requires-port": "^1.0.0" } }, + "node_modules/use-composed-ref": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/use-composed-ref/-/use-composed-ref-1.3.0.tgz", + "integrity": "sha512-GLMG0Jc/jiKov/3Ulid1wbv3r54K9HlMW29IWcDFPEqFkSO2nS0MuefWgMJpeHQ9YJeXDL3ZUF+P3jdXlZX/cQ==", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/use-isomorphic-layout-effect": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/use-isomorphic-layout-effect/-/use-isomorphic-layout-effect-1.1.2.tgz", + "integrity": "sha512-49L8yCO3iGT/ZF9QttjwLF/ZD9Iwto5LnH5LmEdk/6cFmXddqi2ulF0edxTwjj+7mqvpVVGQWvbXZdn32wRSHA==", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, + "node_modules/use-latest": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/use-latest/-/use-latest-1.2.1.tgz", + "integrity": "sha512-xA+AVm/Wlg3e2P/JiItTziwS7FK92LWrDB0p+hgXloIMuVCeJJ8v6f0eeHyPZaJrM+usM1FkFfbNCrJGs8A/zw==", + "dependencies": { + "use-isomorphic-layout-effect": "^1.1.1" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + } + } + }, "node_modules/use-sync-external-store": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz", diff --git a/app/package.json b/app/package.json index dc94d874..700357b9 100644 --- a/app/package.json +++ b/app/package.json @@ -26,6 +26,7 @@ "tailwind-merge": "^2.2.1", "uuid": "^9.0.1", "wasp": "file:.wasp/out/sdk/wasp", + "react-textarea-autosize": "^8.5.3", "zod": "3.22.4" }, "devDependencies": { diff --git a/app/src/client/components/ChatForm.tsx b/app/src/client/components/ChatForm.tsx index 5f8cb1a8..53b49d20 100644 --- a/app/src/client/components/ChatForm.tsx +++ b/app/src/client/components/ChatForm.tsx @@ -1,6 +1,10 @@ -import { type Chat } from 'wasp/entities'; import React, { useRef, useState, useEffect, useCallback } from 'react'; +import _ from 'lodash'; +import TextareaAutosize from 'react-textarea-autosize'; + +import { type Chat } from 'wasp/entities'; + interface ChatFormProps { handleFormSubmit: (userQuery: string) => void; currentChatDetails: Chat; @@ -9,6 +13,8 @@ interface ChatFormProps { export default function ChatForm({ handleFormSubmit, currentChatDetails, triggerChatFormSubmitMsg }: ChatFormProps) { const [formInputValue, setFormInputValue] = useState(''); + const [disableFormSubmit, setDisableFormSubmit] = useState(false); + const [isSubmitting, setIsSubmitting] = useState(false); const formInputRef = useCallback( async (node: any) => { @@ -20,17 +26,30 @@ export default function ChatForm({ handleFormSubmit, currentChatDetails, trigger [triggerChatFormSubmitMsg] ); + useEffect(() => { + if (currentChatDetails) { + setDisableFormSubmit(currentChatDetails.team_status === 'inprogress'); + } else { + setDisableFormSubmit(false); + } + }, [currentChatDetails]); + const handleSubmit = async (event: React.FormEvent) => { event.preventDefault(); + if (isSubmitting || disableFormSubmit) return; + if (!currentChatDetails.showLoader) { setFormInputValue(''); handleFormSubmit(formInputValue); + setIsSubmitting(false); } }; + const debouncedHandleSubmit = _.debounce(handleSubmit, 500); + return (
-
+