Skip to content

Commit e7f6c8d

Browse files
refactpr base url (#184)
1 parent 5dced40 commit e7f6c8d

File tree

8 files changed

+13
-13
lines changed

8 files changed

+13
-13
lines changed

frontend/app/admin/settings/integrations/ChatWidget.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const ChatWidget: React.FC<ChatWidgetProps> = ({ integration, onUpdate }) => {
1414

1515
const widgetCode = `<script type="text/javascript">
1616
!function(win,doc){"use strict";var script_loader=()=>{try
17-
{var head=doc.head||doc.getElementsByTagName("head")[0],script=doc.createElement("script");script.setAttribute("type","text/javascript"),script.setAttribute("src","${process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:8080'}/static/widget/script.js"),head.appendChild(script)}
17+
{var head=doc.head||doc.getElementsByTagName("head")[0],script=doc.createElement("script");script.setAttribute("type","text/javascript"),script.setAttribute("src","https://alfredfrancis.in/ai-chatbot-framework/app/static/widget/script.js"),head.appendChild(script)}
1818
catch(e){}};win.chat_context={"username":"John"},win.iky_base_url="${process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:8080'}",script_loader()}(window,document);
1919
</script>`;
2020

frontend/app/services/agents.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:8080/admin/';
1+
import { API_BASE_URL } from "./base";
22

33
interface AgentConfig {
44
confidence_threshold: number

frontend/app/services/base.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:8080/admin/';

frontend/app/services/chat.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:8080/';
1+
import { API_BASE_URL } from "./base";
22

33
interface UserMessage {
44
thread_id: string;
@@ -49,7 +49,7 @@ interface ChatState {
4949

5050

5151
export const converse = async (userMessage: UserMessage): Promise<ChatState> => {
52-
const response = await fetch(`${API_BASE_URL}admin/test/chat`, {
52+
const response = await fetch(`${API_BASE_URL}test/chat`, {
5353
method: 'POST',
5454
headers: { 'Content-Type': 'application/json' },
5555
body: JSON.stringify(userMessage),

frontend/app/services/entities.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { EntityModel } from './training';
2-
3-
const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:8080/admin/';
2+
import { API_BASE_URL } from "./base";
43

54
export const getEntities = async (): Promise<EntityModel[]> => {
65
const response = await fetch(`${API_BASE_URL}entities/`);

frontend/app/services/integrations.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:8080';
1+
import { API_BASE_URL } from "./base";
22

33
export interface FacebookSettings {
44
verify: string;
@@ -22,15 +22,15 @@ export interface IntegrationDetails<T> extends Integration {
2222
}
2323

2424
export async function listIntegrations(): Promise<Integration[]> {
25-
const response = await fetch(`${baseUrl}/admin/integrations/`);
25+
const response = await fetch(`${API_BASE_URL}integrations/`);
2626
if (!response.ok) {
2727
throw new Error('Failed to fetch integrations');
2828
}
2929
return response.json();
3030
}
3131

3232
export async function getIntegration<T>(integrationID: string): Promise<IntegrationDetails<T>> {
33-
const response = await fetch(`${baseUrl}/admin/integrations/${integrationID}`);
33+
const response = await fetch(`${API_BASE_URL}integrations/${integrationID}`);
3434
if (!response.ok) {
3535
throw new Error('Failed to fetch integration');
3636
}
@@ -44,7 +44,7 @@ export async function updateIntegration<T>(
4444
settings: T;
4545
}
4646
): Promise<IntegrationDetails<T>> {
47-
const response = await fetch(`${baseUrl}/admin/integrations/${integrationID}`, {
47+
const response = await fetch(`${API_BASE_URL}integrations/${integrationID}`, {
4848
method: 'PUT',
4949
headers: {
5050
'Content-Type': 'application/json',

frontend/app/services/intents.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { API_BASE_URL } from "./base";
12
import type { IntentModel } from './training';
23

3-
const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:8080/admin/';
44

55
export const getIntents = async (): Promise<IntentModel[]> => {
66
const response = await fetch(`${API_BASE_URL}intents/`);

frontend/app/services/training.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { API_BASE_URL } from "./base";
2+
13
interface Parameter {
24
name: string;
35
value?: string;
@@ -61,8 +63,6 @@ interface IntentModel {
6163
};
6264
}
6365

64-
const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:8080/admin/';
65-
6666
export const saveTrainingData = async (intentId: string, data: Example[]) => {
6767
const response = await fetch(`${API_BASE_URL}train/${intentId}/data`, {
6868
method: 'POST',

0 commit comments

Comments
 (0)