File tree Expand file tree Collapse file tree 1 file changed +30
-5
lines changed
Expand file tree Collapse file tree 1 file changed +30
-5
lines changed Original file line number Diff line number Diff line change 11import { ChatApiResponse , ChatRequest , FeedbackRequest } from "./apiTypes/chatTypes" ;
22import { httpClient } from "../utils/httpClient/httpClient" ;
33
4+
5+ // export async function Completion(request: ChatRequest){
6+ // const response: ChatApiResponse = await httpClient.post(`https://dpsapi.eastus2.cloudapp.azure.com/chat`, request);
7+
8+ // return response;
9+ // }
10+
411export async function Completion ( request : ChatRequest ) : Promise < ChatApiResponse > {
5- const response : ChatApiResponse = await httpClient . post ( `/chat` , request ) ;
6- return response ;
7- }
12+ try {
13+ // Assuming httpClient is similar to Axios, we pass the request body and expect a ChatApiResponse
14+ const response : ChatApiResponse = await httpClient . post (
15+ `${ import . meta. env . VITE_API_ENDPOINT } /chat` ,
16+ request ,
17+ {
18+ headers : {
19+ 'Content-Type' : 'application/json' , // Ensure JSON format
20+ } ,
21+ }
22+ ) ;
23+
24+ // Return the actual response data (assuming Axios-style response structure)
25+ return response ;
26+ } catch ( error ) {
27+ console . error ( 'Error during API request:' , error ) ;
28+ throw new Error ( 'Failed to fetch the API response.' ) ;
29+ }
30+ }
31+
32+
33+ export async function PostFeedback ( request : FeedbackRequest ) {
34+ const response : boolean = await httpClient . post ( `${ window . ENV . API_URL } /api/Chat/Feedback` , request ) ;
835
9- export async function PostFeedback ( request : FeedbackRequest ) : Promise < boolean > {
10- const response : boolean = await httpClient . post ( `/api/Chat/Feedback` , request ) ;
1136 return response ;
1237}
You can’t perform that action at this time.
0 commit comments