kenken999 commited on
Commit
ab83b4b
1 Parent(s): 514684f
controllers/gra_02_openInterpreter/{__init__.py → __isnit__.py} RENAMED
File without changes
routers/__init__.py DELETED
File without changes
routers/router.py DELETED
@@ -1,66 +0,0 @@
1
- import shutil
2
- import gradio as gr
3
- from mysite.libs.utilities import chat_with_interpreter, completion, process_file
4
- from interpreter import interpreter
5
- import mysite.interpreter.interpreter_config # インポートするだけで設定が適用されます
6
- import importlib
7
- import os
8
- import pkgutil
9
- #from routers.chat.chat import demo44 as demo4
10
- #
11
- #from routers.postg.gradio_app import crud_interface
12
- #from routers.chats.chats import gradio_interface
13
-
14
-
15
- def include_gradio_interfaces():
16
- package_dir = "/home/user/app/controllers"
17
- gradio_interfaces = []
18
- gradio_names = set()
19
-
20
- for module_info in pkgutil.walk_packages([package_dir], "routers."):
21
- sub_module_name = module_info.name
22
- try:
23
- print(f"Trying to import {sub_module_name}")
24
- module = importlib.import_module(sub_module_name)
25
- if hasattr(module, "gradio_interface"):
26
- print(f"Found gradio_interface in {sub_module_name}")
27
- interface_name = module_info.name.split(".")[-1]
28
- if interface_name not in gradio_names:
29
- gradio_interfaces.append(module.gradio_interface)
30
- gradio_names.add(interface_name)
31
- else:
32
- unique_name = f"{interface_name}_{len(gradio_names)}"
33
- gradio_interfaces.append(module.gradio_interface)
34
- gradio_names.add(unique_name)
35
- except ModuleNotFoundError:
36
- print(f"ModuleNotFoundError: {sub_module_name}")
37
- pass
38
- except Exception as e:
39
- print(f"Failed to import {sub_module_name}: {e}")
40
-
41
- print(f"Collected Gradio Interfaces: {gradio_names}")
42
- return gradio_interfaces, list(gradio_names)
43
-
44
- def setup_gradio_interfaces():
45
-
46
- democs = gr.Interface(
47
- fn=process_file,
48
- inputs=[
49
- "file",
50
- gr.Textbox(label="Additional Notes", lines=10),
51
- gr.Textbox(label="Folder Name"),
52
- ],
53
- outputs="text",
54
- )
55
-
56
- default_interfaces = [democs]#,demo]
57
- default_names = ["仕様書から作成","Chat","OpenInterpreter","DataBase"]#"demo"]
58
-
59
- gradio_interfaces, gradio_names = include_gradio_interfaces()
60
-
61
- all_interfaces = default_interfaces + gradio_interfaces
62
- all_names = default_names# + gradio_names
63
-
64
- tabs = gr.TabbedInterface(all_interfaces, all_names)
65
- tabs.queue()
66
- return tabs