{
@@ -518,7 +588,7 @@ export const DocsGPTWidget = ({
type='text' placeholder="What do you want to do?" />
+ disabled={prompt.trim().length == 0 || status !== 'idle'}>
diff --git a/extensions/react-widget/src/requests/streamingApi.ts b/extensions/react-widget/src/requests/streamingApi.ts
index b594915f..9cb9fddc 100644
--- a/extensions/react-widget/src/requests/streamingApi.ts
+++ b/extensions/react-widget/src/requests/streamingApi.ts
@@ -1,3 +1,4 @@
+import { FEEDBACK } from "@/types";
interface HistoryItem {
prompt: string;
response?: string;
@@ -11,6 +12,12 @@ interface FetchAnswerStreamingProps {
apiHost?: string;
onEvent?: (event: MessageEvent) => void;
}
+interface FeedbackPayload {
+ question: string;
+ answer: string;
+ apikey: string;
+ feedback: FEEDBACK;
+}
export function fetchAnswerStreaming({
question = '',
apiKey = '',
@@ -20,12 +27,12 @@ export function fetchAnswerStreaming({
onEvent = () => { console.log("Event triggered, but no handler provided."); }
}: FetchAnswerStreamingProps): Promise
{
return new Promise((resolve, reject) => {
- const body= {
+ const body = {
question: question,
history: JSON.stringify(history),
conversation_id: conversationId,
model: 'default',
- api_key:apiKey
+ api_key: apiKey
};
fetch(apiHost + '/stream', {
method: 'POST',
@@ -80,4 +87,20 @@ export function fetchAnswerStreaming({
reject(error);
});
});
-}
\ No newline at end of file
+}
+
+
+export const sendFeedback = (payload: FeedbackPayload,apiHost:string): Promise => {
+ return fetch(`${apiHost}/api/feedback`, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ body: JSON.stringify({
+ question: payload.question,
+ answer: payload.answer,
+ feedback: payload.feedback,
+ api_key:payload.apikey
+ }),
+ });
+};
\ No newline at end of file
diff --git a/extensions/react-widget/src/types/index.ts b/extensions/react-widget/src/types/index.ts
index cb46f06b..a55b6342 100644
--- a/extensions/react-widget/src/types/index.ts
+++ b/extensions/react-widget/src/types/index.ts
@@ -23,4 +23,5 @@ export interface WidgetProps {
theme?:THEME,
buttonIcon?:string;
buttonBg?:string;
+ collectFeedback?:boolean
}
\ No newline at end of file