Skip to content

Commit

Permalink
Merge branch 'main' into dev_update_libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
yuxumin authored Sep 20, 2024
2 parents 8512143 + a2e17f4 commit cd27de8
Show file tree
Hide file tree
Showing 10 changed files with 274 additions and 32 deletions.
167 changes: 167 additions & 0 deletions .github/workflows/stable-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@

name: "Release To HF"

on:
workflow_dispatch:
inputs:
git_tag:
description: 'Git Branch Tag'
required: true
type: string
default: "main"
cu:
description: 'CUDA Version'
required: true
type: string
default: "124"
python_minor:
description: 'Python Minor Version'
required: true
type: string
default: "10"
python_patch:
description: 'Python Patch Version'
required: true
type: string
default: "10"
version:
description: 'Release Version Tag'
required: true
type: string
default: "beta"

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
ref: ${{ inputs.git_tag }}

- uses: pnpm/action-setup@v2
with:
version: 9
run_install: false

- uses: actions/setup-node@v4
with:
node-version: "20"
cache: "pnpm"
cache-dependency-path: "web/pnpm-lock.yaml"

- working-directory: "./web"
run: pnpm install

- working-directory: "./web"
run: pnpm turbo run build --filter=web

- uses: actions/upload-artifact@v3
with:
name: web-build
path: web/apps/web/dist

package_shellagent_windows:
permissions:
contents: "write"
packages: "write"
pull-requests: "read"
needs: build
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.git_tag }}
fetch-depth: 0
persist-credentials: false
submodules: recursive
- uses: actions/setup-python@v5
with:
python-version: 3.${{ inputs.python_minor }}.${{ inputs.python_patch }}

- name: Download web-build artifact
uses: actions/download-artifact@v3
with:
name: web-build
path: ./servers/web-build

- shell: bash
run: |
cd ..
cp -r ShellAgent ShellAgent_copy
curl -L https://huggingface.co/XuminYu/git_embed/resolve/main/git.7z?download=true -o git.7z
"C:\Program Files\7-Zip\7z.exe" x git.7z -ogit
curl https://www.python.org/ftp/python/3.${{ inputs.python_minor }}.${{ inputs.python_patch }}/python-3.${{ inputs.python_minor }}.${{ inputs.python_patch }}-embed-amd64.zip -o python_embeded.zip
unzip python_embeded.zip -d python_embeded
cd python_embeded
echo 'import site' >> ./python3${{ inputs.python_minor }}._pth
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
./python.exe get-pip.py
cp -r ../ShellAgent/.ci/python_dependencies_wins/include ./include
cp -r ../ShellAgent/.ci/python_dependencies_wins/Library ./Library
cp -r ../ShellAgent/.ci/python_dependencies_wins/libs ./libs
./python.exe -s -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu${{ inputs.cu }}
./python.exe -s -m pip install --use-pep517 pygit2 Cython scikit_build_core enscons pytoml cmake==3.21
./python.exe -s -m pip install --use-pep517 -r ../ShellAgent/requirements.txt
./python.exe -s -m pip install onnx==1.16.1 flask PyExecJS docx2txt fuzzywuzzy git cloudpickle
sed -i '1i../ShellAgent' ./python3${{ inputs.python_minor }}._pth
cd ..
mkdir ShellAgent_windows_portable
mv python_embeded ShellAgent_windows_portable
mv git ShellAgent_windows_portable
mv ShellAgent_copy ShellAgent_windows_portable/ShellAgent
cd ShellAgent_windows_portable
cp -r ShellAgent/.ci/windows_base_files/* ./
cd ShellAgent
mkdir -p models/insightface/models
ls models/insightface/
curl -L https://huggingface.co/MonsterMMORPG/tools/resolve/main/antelopev2.zip -o models/insightface/models/antelopev2.zip
ls models/insightface/models/
unzip models/insightface/models/antelopev2.zip -d models/insightface/models/
mkdir -p models/vae_approx
ls models
git clone --depth 1 https://github.com/comfyanonymous/taesd
cp taesd/*.pth models/vae_approx
../python_embeded/python.exe -m pip install -e .
../python_embeded/python.exe -m pip show proconfig
# ../python_embeded/python.exe servers/main.py
cd ..
cd ..
"C:\Program Files\7-Zip\7z.exe" a -t7z -m0=lzma2 -mx=8 -mfb=64 -md=32m -ms=on -mf=BCJ2 ShellAgent_windows_portable.7z ShellAgent_windows_portable/*
mv ShellAgent_windows_portable.7z ShellAgent/ShellAgent_windows_portable.7z
ls
- name: Install Hugging Face Hub SDK
run: pip install huggingface_hub

- name: Upload binaries to Hugging Face
run: |
from huggingface_hub import HfApi
api = HfApi()
# Set repository and file paths
repo_id = "myshell-ai/ShellAgent"
file_path = "ShellAgent_windows_portable.7z"
# Upload the file to Hugging Face repository
api.upload_file(
path_or_fileobj=file_path,
path_in_repo="ShellAgent_${{ inputs.version }}.7z",
repo_id=repo_id,
repo_type="model", # or 'dataset' depending on your use case
token="${{ secrets.HF_TOKEN }}"
)
shell: python
23 changes: 4 additions & 19 deletions web/apps/web/src/components/workflow/import-modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const ImportModal: React.FC<{
onOpenChange: (open: boolean) => void;
}> = ({ open, onOpenChange }) => {
const [openTips, setOpenTips] = useBoolean(false);
const [isExpand, isExpandAction] = useBoolean(false);
const [fileUrl, setFileUrl] = useState<string | undefined>();
const [workflow, setWorkflow] = useState<Workflow | undefined>();
const { existedInfo, importWorkflow, setExistedInfo } = useWorkflowStore(
Expand Down Expand Up @@ -204,31 +203,17 @@ const ImportModal: React.FC<{
</AlertDialogTitle>
</AlertDialogHeader>
<AlertDialogDescription className="flex flex-col gap-1.5">
<Heading size="h2">Warning</Heading>
<Heading size="h2">Missing Items</Heading>
<Text size="sm" color="subtle">
The following items are missing.
<br />
Replace it with installed models/widgets, or contact us to add
it to the standard environment.
If this workflow would run in MyShell, please replace the
missing models/widgets with similar installed ones, or contact
us to add them to the standard environment.
</Text>
<div
className="flex items-center cursor-pointer"
onClick={() => isExpandAction.toggle()}>
<Text size="sm" color="subtler">
{isExpand ? 'Show Less' : 'View Detail'}
</Text>
<ChevronDownIcon
className={cn('w-4 h-4 ml-1.5 text-subtler', {
'rotate-180': isExpand,
})}
/>
</div>
<div
className={cn(
'flex-1 rounded-lg border border-default p-3 w-[340px] max-h-60 overflow-x-hidden',
{
hidden: !isExpand,
},
)}>
{!isEmpty(existedInfo.non_existed_models) ? (
<div>
Expand Down
19 changes: 16 additions & 3 deletions web/apps/web/src/components/workflow/node-card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,19 @@ const NodeCard: React.FC<
NodeData & {
children: React.ReactNode;
selected?: boolean;
has_error?: boolean;
mode?: string;
}
> = ({ id, children, runtime_data, selected, name, display_name, mode }) => {
> = ({
id,
children,
runtime_data,
selected,
name,
display_name,
mode,
has_error,
}) => {
const selectRef = useRef(null);
const active = useHover(selectRef);
const isUndefined = mode === 'undefined';
Expand All @@ -35,7 +45,9 @@ const NodeCard: React.FC<
},
{
'!border-critical':
runtime_data?.node_status === NodeStatusEnum.failed || isUndefined,
runtime_data?.node_status === NodeStatusEnum.failed ||
isUndefined ||
has_error,
},
{
'!border-brand': runtime_data?.node_status === NodeStatusEnum.start,
Expand All @@ -48,13 +60,14 @@ const NodeCard: React.FC<
<SchemaProvider
id={id}
name={name}
mode={mode}
display_name={display_name}
output={runtime_data?.output}>
<ContextMenu>
{isUndefined ? (
<div className="pb-2">
<Heading size="h1" color="critical">
Undefined Widget
Missing Widget
</Heading>
<Text color="critical">
Replace it with installed widgets, or contact us to add it to
Expand Down
15 changes: 14 additions & 1 deletion web/apps/web/src/components/workflow/node-form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,22 @@ interface NodeFormProps {
loading?: boolean;
modeMap?: Record<string, TFieldMode>;
onModeChange?: (name: string, mode: TFieldMode) => void;
onStatusChange?: (status: { [key: string]: string }) => void;
}

const NodeForm = forwardRef<FormRef, NodeFormProps>(
({ values, onChange, schema, loading, onModeChange, modeMap }, ref) => {
(
{
values,
onChange,
schema,
loading,
onModeChange,
onStatusChange,
modeMap,
},
ref,
) => {
const { schema: formSchema, formKey } = useSchemaContext(state => ({
schema: state.schema,
formKey: state.formKey,
Expand Down Expand Up @@ -78,6 +90,7 @@ const NodeForm = forwardRef<FormRef, NodeFormProps>(
schema={currentSchema}
modeMap={modeMap}
onModeChange={onModeChange}
onStatusChange={onStatusChange}
components={{
Input,
Select,
Expand Down
24 changes: 22 additions & 2 deletions web/apps/web/src/components/workflow/nodes/widget-node/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import {
import { TValues, TFieldMode } from '@shellagent/form-engine';
import { FormRef } from '@shellagent/ui';
import { useKeyPress } from 'ahooks';
import React, { useCallback, useRef, useEffect } from 'react';
import React, {
useCallback,
useRef,
useEffect,
useState,
useMemo,
} from 'react';
import { useShallow } from 'zustand/react/shallow';

import { useWorkflowState } from '@/stores/workflow/use-workflow-state';
Expand All @@ -21,6 +27,7 @@ import { useDuplicateState } from './hook/use-duplicate-state';
import { EventType, useEventEmitter } from '../../emitter';
import NodeCard from '../../node-card';
import NodeForm from '../../node-form';
import { some } from 'lodash-es';

const WidgetNode: React.FC<NodeProps<WidgetNodeType>> = ({
id,
Expand All @@ -29,6 +36,7 @@ const WidgetNode: React.FC<NodeProps<WidgetNodeType>> = ({
}) => {
const formRef = useRef<FormRef>(null);
const nodeRef = useRef<HTMLElement | null>(null);
const statusRef = useRef({});
const { duplicateState } = useDuplicateState(id);
const { onDelNode } = useReactFlowStore(state => ({
onDelNode: state.onDelNode,
Expand All @@ -37,6 +45,8 @@ const WidgetNode: React.FC<NodeProps<WidgetNodeType>> = ({
setCurrentCopyId: state.setCurrentCopyId,
}));

const [hasError, setHasError] = useState(false);

const {
setNodeData,
nodeData,
Expand Down Expand Up @@ -144,14 +154,24 @@ const WidgetNode: React.FC<NodeProps<WidgetNodeType>> = ({
}
});

const onStatusChange = (obj: { [key: string]: string }) => {
statusRef.current = { ...statusRef.current, ...obj };
setHasError(some(statusRef.current, value => value === 'missOption'));
};

return (
<NodeCard selected={selected} mode={nodeData[data.id]?.mode} {...data}>
<NodeCard
selected={selected}
mode={nodeData[data.id]?.mode}
has_error={some(statusRef.current, value => value === 'missOption')}
{...data}>
<NodeForm
ref={formRef}
loading={loading.getReactFlow}
values={nodeData[data.id]}
onChange={onChange}
onModeChange={onModeChange}
onStatusChange={onStatusChange}
modeMap={fieldsModeMap?.[data.id] || {}}
/>
</NodeCard>
Expand Down
10 changes: 6 additions & 4 deletions web/apps/web/src/stores/workflow/schema-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ export const useSchemaContext = <T,>(

export interface SchemaProviderProps {
id: string;
name: string | undefined;
display_name: string | undefined;
name?: string;
mode?: string;
display_name?: string;
children: React.ReactNode | React.ReactNode[];
output?: Record<string, any>;
}

export const SchemaProvider: React.FC<SchemaProviderProps> = ({
name = '',
mode,
display_name = '',
id,
children,
Expand Down Expand Up @@ -122,7 +124,7 @@ export const SchemaProvider: React.FC<SchemaProviderProps> = ({
memoized.schema = endSchema;
} else if (!isEmpty(currentWidgetSchema)) {
const schema = getSchemaByWidget({
name: display_name,
name: mode === 'undefined' ? name : display_name,
inputSchema: currentWidgetSchema?.input_schema,
outputSchema: currentWidgetSchema?.output_schema,
fieldsModeMap: currentFieldsModeMap,
Expand All @@ -142,7 +144,7 @@ export const SchemaProvider: React.FC<SchemaProviderProps> = ({
outputs: memoized.outputRefTypes,
});
return memoized;
}, [id, name, display_name, currentWidgetSchema, currentFieldsModeMap]);
}, [id, mode, name, display_name, currentWidgetSchema, currentFieldsModeMap]);

const formKey = useMemo(() => {
return `${JSON.stringify({
Expand Down
Loading

0 comments on commit cd27de8

Please sign in to comment.