From 30936aa8090037b9d4506c9bee87f94188bc08f4 Mon Sep 17 00:00:00 2001 From: cyrbuzz Date: Thu, 20 Feb 2025 15:25:05 +0800 Subject: [PATCH] chore: update ai url --- .env | 4 +-- src/containers/QueryApolloProvider.tsx | 40 ++++++++++++++------------ 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/.env b/.env index 64117adf..43288d33 100644 --- a/.env +++ b/.env @@ -9,5 +9,5 @@ VITE_NETWORK_DEPLOYMENT_ID=QmWaV7Be6KwdhU6v6tUaVCyb1R3rUxYX987fGNJkQ4QisU VITE_PROXYGATEWAY=https://gateway.subquery.network VITE_SUBQUERY_OFFICIAL_BASE_RPC=https://base.rpc.subquery.network/public VITE_SUBQUERY_OFFICIAL_ETH_RPC=https://ethereum.rpc.subquery.network/public -VITE_AI_URL=https://ai-network.thechaindata.com/v1/chat/completions -VITE_AI_REACTION_URL=https://ai-reaction-backend.thechaindata.com \ No newline at end of file +VITE_AI_URL=https://ai-network.subquery.network/v1/chat/completions +VITE_AI_REACTION_URL=https://ai-reaction-backend.subquery.network \ No newline at end of file diff --git a/src/containers/QueryApolloProvider.tsx b/src/containers/QueryApolloProvider.tsx index 006e76c7..722efbbe 100644 --- a/src/containers/QueryApolloProvider.tsx +++ b/src/containers/QueryApolloProvider.tsx @@ -18,32 +18,34 @@ const gatewayLink = getHttpLink( ); const fallbackLink = getHttpLink(import.meta.env.VITE_QUERY_REGISTRY_PROJECT); -export const networkLink = new ApolloLink((operation) => { - return new Observable((observer) => { - operation.setContext({ - headers: { - 'X-Ping': uuidv4(), - }, - }); - gatewayLink.request(operation)?.subscribe({ - next(value) { - observer.next(value); - observer.complete(); - }, - error: () => { - fallbackLink.request(operation)?.subscribe({ +export const networkLink = import.meta.env.VITE_USE_FALLBACKURL + ? fallbackLink + : new ApolloLink((operation) => { + return new Observable((observer) => { + operation.setContext({ + headers: { + 'X-Ping': uuidv4(), + }, + }); + gatewayLink.request(operation)?.subscribe({ next(value) { observer.next(value); observer.complete(); }, - error: (error) => { - observer.error(error); + error: () => { + fallbackLink.request(operation)?.subscribe({ + next(value) { + observer.next(value); + observer.complete(); + }, + error: (error) => { + observer.error(error); + }, + }); }, }); - }, + }); }); - }); -}); const links = ApolloLink.from([ onError(({ graphQLErrors, operation, networkError }) => {