-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bot UI See merge request postgres-ai/database-lab!856
- Loading branch information
Showing
49 changed files
with
3,324 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
REACT_APP_API_URL_PREFIX=https://v2.postgres.ai/api/general | ||
REACT_APP_TOKEN_DEBUG=__YOUR_JWT_TOKEN_FROM_STAGING__ | ||
REACT_APP_WS_URL=ws://127.0.0.1:9100/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,9 @@ ENV REACT_APP_STRIPE_API_KEY=$ARG_REACT_APP_STRIPE_API_KEY | |
ARG ARG_REACT_APP_SENTRY_DSN | ||
ENV REACT_APP_SENTRY_DSN=$ARG_REACT_APP_SENTRY_DSN | ||
|
||
ARG ARG_REACT_APP_WS_URL | ||
ENV REACT_APP_WS_URL=$ARG_REACT_APP_WS_URL | ||
|
||
RUN apk add --no-cache --update git && \ | ||
npm i -g [email protected]; \ | ||
pnpm config set store-dir /app/.pnpm-store; \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,10 @@ export REACT_APP_ROOT_URL="https://postgres.ai" | |
export PUBLIC_URL="" | ||
|
||
# Public Stripe key, it is ok to keep it here. | ||
export REACT_APP_STRIPE_API_KEY="pk_live_X5yTnxXNtoVDl4Rl5oxY6X1400fwxOS1x3" | ||
export REACT_APP_STRIPE_API_KEY="xxx" | ||
|
||
# Sentry. | ||
export REACT_APP_SENTRY_DSN="https://[email protected]/2" | ||
|
||
# AI Bot | ||
export REACT_APP_WS_URL="wss://postgres.ai/ai-bot-wss/" # don't forget trailing slash! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {request} from "../../helpers/request"; | ||
import {BotMessage} from "../../types/api/entities/bot"; | ||
|
||
type Req = { | ||
query?: string | ||
} | ||
|
||
export const getChats = async (req: Req): Promise<{ response: BotMessage[] | null; error: Response | null }> => { | ||
const { query } = req; | ||
|
||
const apiServer = process.env.REACT_APP_API_URL_PREFIX || ''; | ||
|
||
try { | ||
const response = await request(`${apiServer}/chats${query ? query : ''}`, { | ||
method: 'GET', | ||
}); | ||
|
||
if (!response.ok) { | ||
return { response: null, error: response }; | ||
} | ||
|
||
const responseData: BotMessage[] = await response.json(); | ||
|
||
return { response: responseData, error: null }; | ||
|
||
} catch (error) { | ||
return { response: null, error: error as Response }; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
ui/packages/platform/src/api/bot/getChatsWithWholeThreads.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import {request} from "../../helpers/request"; | ||
import {BotMessage} from "../../types/api/entities/bot"; | ||
|
||
type Req = { | ||
id: string | ||
} | ||
|
||
export const getChatsWithWholeThreads = async (req: Req): Promise<{ response: BotMessage[] | null; error: Response | null }> => { | ||
const { id } = req; | ||
|
||
const apiServer = process.env.REACT_APP_API_URL_PREFIX || ''; | ||
|
||
try { | ||
const response = await request(`${apiServer}/rpc/chats_ancestors_and_descendants`, { | ||
method: 'POST', | ||
body: JSON.stringify({ id }), | ||
}); | ||
|
||
if (!response.ok) { | ||
return { response: null, error: response }; | ||
} | ||
|
||
const responseData: BotMessage[] = await response.json(); | ||
|
||
return { response: responseData, error: null }; | ||
|
||
} catch (error) { | ||
return { response: null, error: error as Response }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import {request} from "../../helpers/request"; | ||
import {BotMessage} from "../../types/api/entities/bot"; | ||
|
||
type Req = { | ||
thread_id: string, | ||
is_public: boolean | ||
} | ||
|
||
export const makeChatPublic = async (req: Req): Promise<{ response: BotMessage | null; error: Response | null }> => { | ||
const { thread_id, is_public } = req; | ||
|
||
const apiServer = process.env.REACT_APP_API_URL_PREFIX || ''; | ||
|
||
try { | ||
const response = await request(`${apiServer}/chats_internal?thread_id=eq.${thread_id}`, { | ||
method: 'PATCH', | ||
headers: { | ||
Prefer: 'return=representation' | ||
}, | ||
body: JSON.stringify({ | ||
is_public | ||
}) | ||
}); | ||
|
||
if (!response.ok) { | ||
return { response: null, error: response }; | ||
} | ||
|
||
const responseData: BotMessage = await response.json(); | ||
|
||
return { response: responseData, error: null }; | ||
|
||
} catch (error) { | ||
return { response: null, error: error as Response }; | ||
} | ||
} |
Oops, something went wrong.