diff --git a/chatglm/code_kernel.py b/chatglm/code_kernel.py index 48ab6a7..cc4c6ec 100644 --- a/chatglm/code_kernel.py +++ b/chatglm/code_kernel.py @@ -1,14 +1,15 @@ import base64 -from io import BytesIO import os -from pprint import pprint import queue import re +import time +from io import BytesIO +from pprint import pprint from subprocess import PIPE -from typing import Dict, Union, Optional, Tuple +from typing import Dict, Optional, Tuple, Union + import jupyter_client from PIL import Image -import time IPYKERNEL = os.environ.get('IPYKERNEL', 'chatglm3') diff --git a/chatglm/comfyUI_api.py b/chatglm/comfyUI_api.py index e856f83..aefe6cc 100644 --- a/chatglm/comfyUI_api.py +++ b/chatglm/comfyUI_api.py @@ -1,14 +1,15 @@ # This is an example that uses the websockets api to know when a prompt execution is done # Once the prompt execution is done it downloads the images using the /history endpoint +import io +import json +import random +import urllib +import uuid + +import requests # NOTE: websocket-client (https://github.com/websocket-client/websocket-client) import websocket -import uuid -import json -import requests -import urllib -import random -import io from PIL import Image @@ -178,7 +179,8 @@ if __name__ == '__main__': for node_id in images: for image_data in images[node_id]: - from PIL import Image import io + + from PIL import Image image = Image.open(io.BytesIO(image_data)) image.show() diff --git a/chatglm/tool_registry.py b/chatglm/tool_registry.py index 5bdbdba..8758b16 100644 --- a/chatglm/tool_registry.py +++ b/chatglm/tool_registry.py @@ -1,18 +1,20 @@ -from copy import deepcopy import inspect -from pprint import pformat -import traceback -from types import GenericAlias -from typing import get_origin, Annotated import json -import requests import random -import time import re -from chatglm.comfyUI_api import ComfyUIApi +import time +import traceback +from copy import deepcopy +from datetime import datetime +from pprint import pformat +from types import GenericAlias +from typing import Annotated, get_origin + +import requests from func_news import News from zhdate import ZhDate -from datetime import datetime + +from chatglm.comfyUI_api import ComfyUIApi _TOOL_HOOKS = {} _TOOL_DESCRIPTIONS = {} diff --git a/func_chatglm.py b/func_chatglm.py index 4cbb926..9fe57f3 100644 --- a/func_chatglm.py +++ b/func_chatglm.py @@ -1,17 +1,18 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -from datetime import datetime - -import openai import json import os import random -from chatglm.tool_registry import get_tools, dispatch_tool, extract_code -from chatglm.code_kernel import execute, CodeKernel -from typing import Dict, Union, Optional, Tuple +from datetime import datetime +from typing import Dict, Optional, Tuple, Union + +import openai from wcferry import Wcf +from chatglm.code_kernel import CodeKernel, execute +from chatglm.tool_registry import dispatch_tool, extract_code, get_tools + functions = get_tools() diff --git a/requirements.txt b/requirements.txt index e82bf35..5950519 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,3 +12,4 @@ websocket pillow jupyter_client zhdate +ipykernel \ No newline at end of file