Skip to content

Commit

Permalink
Merge branch 'main' of github.com:fhswf/openai-ui into main
Browse files Browse the repository at this point in the history
  • Loading branch information
cgawron committed Mar 20, 2024
2 parents a7b9f20 + 9703a6a commit d14b8a5
Show file tree
Hide file tree
Showing 17 changed files with 213 additions and 125 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,22 @@ jobs:
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
steps:
- name: ci-install token
id: cicd
uses: getsentry/action-github-app-token@v2
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Semantic Release
id: semantic_release
uses: cycjimmy/semantic-release-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ steps.cicd.outputs.token }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Set default (old) release version
Expand All @@ -43,6 +50,12 @@ jobs:
needs: release
runs-on: ubuntu-latest
steps:
- name: ci-install token
id: cicd
uses: getsentry/action-github-app-token@v2
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
Expand Down Expand Up @@ -83,6 +96,7 @@ jobs:
- name: Update yaml
uses: fjogeleit/yaml-update-action@main
with:
token: ${{ steps.cicd.outputs.token }}
valueFile: 'k8s/deployment-dev.yaml'
propertyPath: 'spec.template.spec.containers[0].image'
value: ghcr.io/fhswf/openai-ui:${{ env.DOCKER_METADATA_OUTPUT_VERSION }}
Expand Down
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
## [0.5.4](https://github.com/fhswf/openai-ui/compare/v0.5.3...v0.5.4) (2024-03-20)


### Bug Fixes

* favicon ([e14c8e3](https://github.com/fhswf/openai-ui/commit/e14c8e3d7a46f39f04269d16047348ecef3dae04))
* markdown highlighting ([5b4c8ac](https://github.com/fhswf/openai-ui/commit/5b4c8ac052f124c345cc6441705dea428c640c85))

## [0.5.3](https://github.com/fhswf/openai-ui/compare/v0.5.2...v0.5.3) (2024-03-20)


### Bug Fixes

* workflow permissions ([b76fc30](https://github.com/fhswf/openai-ui/commit/b76fc30efffd265f28e2bd98a23d27713aa24147))

## [0.5.2](https://github.com/fhswf/openai-ui/compare/v0.5.1...v0.5.2) (2024-03-20)


### Bug Fixes

* cookies for cors ([1c24d60](https://github.com/fhswf/openai-ui/commit/1c24d60729378f455ea999306d91685fe7c57920))

## [0.5.1](https://github.com/fhswf/openai-ui/compare/v0.5.0...v0.5.1) (2024-03-19)


### Bug Fixes

* option passing to openai service ([fd486b1](https://github.com/fhswf/openai-ui/commit/fd486b19245f5c21a17d5212d70b89ca8f6cf333))

# [0.5.0](https://github.com/fhswf/openai-ui/compare/v0.4.2...v0.5.0) (2024-03-19)


Expand Down
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link rel="icon" href="favicon.png" type="image/png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>GPT-CHAT</title>
<title>K!mpuls, der FH Chatbot</title>
</head>

<body>
Expand Down
2 changes: 1 addition & 1 deletion k8s/deployment-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
io.kompose.service: openai-ui
spec:
containers:
- image: ghcr.io/fhswf/openai-ui:sha-9cda321
- image: ghcr.io/fhswf/openai-ui:sha-e612fb4
name: ui
ports:
- containerPort: 80
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openai-ui",
"version": "0.5.0",
"version": "0.5.4",
"description": "Privacy-focused UI for OpenAI APIs",
"main": "index.js",
"keywords": [],
Expand All @@ -9,7 +9,7 @@
"type": "module",
"private": true,
"scripts": {
"start": "vite",
"start": "NODE_ENV='production' vite",
"build": "vite build"
},
"dependencies": {
Expand Down
Binary file removed public/favicon.ico
Binary file not shown.
Binary file added public/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 15 additions & 4 deletions src/assets/style/common.less
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,30 @@
--text-color: #dfe2eb;
--text-color-gray: #a7acbb;
}

[data-size="small"] {
--font-size-base: 12px;
}

[data-size="middle"] {
--font-size-base: 13px;
}

[data-size="default"] {
--font-size-base: 14px;
}

[data-size="large"] {
--font-size-base: 16px;
}

html {
background-color: var(--background-color-gray);
}

* {
vertical-align: baseline;
font-weight: inherit;
font-family: inherit;
font-style: inherit;

font-size: 100%;
outline: 0;
padding: 0;
Expand All @@ -102,35 +105,43 @@ textarea {
color: var(--text-color);
display: block;
width: 100%;

&::placeholder {
color: var(--text-color-gray);
}
}

body {
font-family: sans-serif;
color: var(--text-color);
}

.flex {
display: flex;

&-c {
display: flex;
align-items: center;

&-c {
display: flex;
align-items: center;
justify-content: center;
}

&-sb {
display: flex;
align-items: center;
justify-content: space-between;
}
}

&-column {
display: flex;
flex-direction: column;
}

&-1 {
flex: 1;
}
}
}
4 changes: 2 additions & 2 deletions src/chat/MessageRender.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { memo } from 'react'
import ReactMarkdown from 'react-markdown'
import Markdown from 'react-markdown'
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'
import { oneLight, oneDark } from 'react-syntax-highlighter/dist/esm/styles/prism'
import { useGlobal } from './context'
Expand All @@ -14,7 +14,7 @@ export const MessageRender = memo((props) => {
const { options } = useGlobal()
const style = options.general.theme === 'dark' ? oneDark : oneLight
return (
<ReactMarkdown
<Markdown
className="z-ui-markdown"
children={props.children}
remarkPlugins={[remarkMath, remarkGfm, remarkBreaks]}
Expand Down
50 changes: 19 additions & 31 deletions src/chat/context/action.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,14 @@
import { fetchStream } from "../service/index";
import i18next, { t, use } from "i18next";
import { useApps } from "../apps/context";
import { AccountOptions, GeneralOptions, GlobalState, OpenAIOptions, Options, OptionAction } from ".";

export type GlobalAction = {
setState: (payload: Partial<GlobalState>) => void;
clearTypeing: () => void;
sendMessage: () => void;
setApp: (app: any) => void;
newChat: (app: any) => void;
modifyChat: (arg: any, index: number) => void;
editChat: (index: number, title: string) => void;
removeChat: (index: number) => void;
setMessage: (content: string) => void;
clearMessage: () => void;
removeMessage: (id: number) => void;
setOptions: (arg: OptionAction) => void;
setIs: (arg: any) => void;
currentList: () => any;
stopResonse: () => void;
};

export default function action(state, dispatch): GlobalAction {
const setState = (payload = {}) =>
import { AccountOptions, GeneralOptions, GlobalState, OpenAIOptions, Options, OptionAction, GlobalActions, Messages, GlobalAction, GlobalActionType, AnyOptions, OptionActionType } from "./types";
import React from "react";


export default function action(state: Partial<GlobalState>, dispatch: React.Dispatch<GlobalAction>): GlobalActions {
const setState = (payload: Partial<GlobalState> = {}) =>
dispatch({
type: "SET_STATE",
type: GlobalActionType.SET_STATE,
payload: { ...payload },
});
return {
Expand Down Expand Up @@ -53,13 +37,13 @@ export default function action(state, dispatch): GlobalAction {
},

async newChat(app) {
const { _currentApp, is, options, currentChat, chat } = state;
const currentApp = app || _currentApp;
let messages = [{ content: currentApp?.content || t("system_welcome"), sentTime: Date.now(), role: "system", id: 1, }]
console.log("newChat: ", currentApp, chat)
const { currentApp, is, options, currentChat, chat } = state;
const newApp = app || currentApp;
let messages = [{ content: newApp?.content || t("system_welcome"), sentTime: Date.now(), role: "system", id: 1, }]
console.log("newChat: ", newApp, chat)
const chatList = [
{
title: currentApp?.title || t("new_conversation"),
title: newApp?.title || t("new_conversation"),
id: Date.now(),
messages,
ct: Date.now(),
Expand All @@ -70,7 +54,7 @@ export default function action(state, dispatch): GlobalAction {
let _chat = chatList;
setState({ chat: _chat, currentChat: 0 });
console.log("newChat: ", _chat)
if (currentApp.botStarts) {
if (newApp.botStarts) {
console.log("botStarts");
await executeChatRequest(setState, is, _chat, messages, options, 0, chat);
}
Expand All @@ -84,7 +68,8 @@ export default function action(state, dispatch): GlobalAction {

editChat(index, title) {
const chat = [...state.chat];
chat.splice(index, 1, [...chat[index], title]);
const _chat = { ...chat[index], title };
chat.splice(index, 1, _chat);
setState({
chat,
});
Expand Down Expand Up @@ -134,12 +119,15 @@ export default function action(state, dispatch): GlobalAction {
setOptions({ type, data }: OptionAction) {
console.log('set options: ', type, data);
let options = { ...state.options };
if (type === OptionActionType.OPENAI) {
}
options[type] = { ...options[type], ...data };
if (type === "general") {
if (data.language) {
i18next.changeLanguage(data.language);
}
}
console.log('set options: ', options);
setState({ options });
},

Expand All @@ -160,7 +148,7 @@ export default function action(state, dispatch): GlobalAction {
};
}

async function executeChatRequest(setState, is, newChat, messages, options: Options, currentChat, chat) {
async function executeChatRequest(setState, is, newChat, messages: Messages, options: Options, currentChat, chat) {
setState({
is: { ...is, thinking: true },
typeingMessage: {},
Expand Down
Loading

0 comments on commit d14b8a5

Please sign in to comment.