Skip to content

Commit

Permalink
Pr/290 (#295)
Browse files Browse the repository at this point in the history
* Add getServiceUrl

* fixed proxy url for chat

* fixed prettier

* removed unused logic

---------

Co-authored-by: Janaka-Steph <[email protected]>
  • Loading branch information
filopedraz and Janaka-Steph authored Jul 20, 2023
1 parent d90f7a2 commit 3f781b4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
6 changes: 6 additions & 0 deletions caddy/Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
:8000 {
handle_path /api/* {
reverse_proxy premd:8000
}
reverse_proxy prem_app:1420
}
17 changes: 10 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,25 @@ services:
prem_app:
container_name: prem_app
build: .
ports:
- 1420:1420
environment:
- VITE_DESTINATION=browser
- VITE_IS_PACKAGED=true
- VITE_BACKEND_URL=http://localhost:8000

premd:
container_name: premd
image: ghcr.io/premai-io/premd:latest
ports:
- 8000:8000
image: ghcr.io/premai-io/premd:v0.0.20
restart: on-failure
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- PREM_REGISTRY_URL=https://raw.githubusercontent.com/premAI-io/prem-registry/main/manifests.json
- SENTRY_DSN=https://[email protected]/4505244431941632


caddy:
container_name: caddy
image: caddy:2.6.4-alpine
restart: on-failure
ports:
- 8000:8000
volumes:
- ./caddy/Caddyfile:/etc/caddy/Caddyfile
6 changes: 2 additions & 4 deletions src/shared/api/v1.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import axios from "axios";
import { getBackendUrlFromStore } from "shared/store/setting";
import { getBackendUrlFromStore } from "../store/setting";

const api = () => {
const client = axios.create({
return axios.create({
baseURL: getBackendUrlFromStore(),
headers: {
"Content-Type": "application/json",
},
});

return client;
};

export default api;
10 changes: 7 additions & 3 deletions src/shared/hooks/usePremChatStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { PremChatResponse } from "modules/prem-chat/types";
import usePremChatStore from "../store/prem-chat";
import useService from "./useService";
import { toast } from "react-toastify";
import { generateUrl } from "shared/helpers/utils";
import { getBackendUrlFromStore } from "shared/store/setting";
import { AxiosError } from "axios";

Expand Down Expand Up @@ -78,11 +79,14 @@ const usePremChatStream = (serviceId: string, chatId: string | null): PremChatRe
setLoading(true);
abortController.current = new AbortController();

const backendUrl = new URL(getBackendUrlFromStore());
backendUrl.port = `${service?.runningPort!}`;
const backendUrl = generateUrl(
getBackendUrlFromStore(),
service?.runningPort!,
"v1/chat/completions"
);

try {
fetchEventSource(`${backendUrl}v1/chat/completions`, {
fetchEventSource(backendUrl, {
method: "POST",
openWhenHidden: true,
headers: {
Expand Down

0 comments on commit 3f781b4

Please sign in to comment.