Spaces:
Sleeping
Sleeping
no more temp dir in huggingface demo
Browse files- hf_transformers_demo.py +3 -26
hf_transformers_demo.py
CHANGED
@@ -1,30 +1,7 @@
|
|
1 |
-
import requests
|
2 |
-
import zipfile
|
3 |
-
import io
|
4 |
from knowlang.chat_bot.chat_interface import create_chatbot
|
5 |
from knowlang.configs.config import AppConfig
|
6 |
-
import tempfile
|
7 |
-
from rich.console import Console
|
8 |
|
9 |
-
console = Console()
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
with console.status("Downloading and extracting codebase...") as status:
|
15 |
-
config.db.codebase_directory = temp_dir
|
16 |
-
status.update(f"Downloading codebase into {temp_dir}...\n")
|
17 |
-
|
18 |
-
|
19 |
-
# Download and unzip the code
|
20 |
-
url = "https://github.com/huggingface/transformers/archive/refs/tags/v4.48.1.zip"
|
21 |
-
response = requests.get(url)
|
22 |
-
zip_file = zipfile.ZipFile(io.BytesIO(response.content))
|
23 |
-
status.update(f"Extracting codebase...\n")
|
24 |
-
|
25 |
-
# Extract the zip file into the codebase directory
|
26 |
-
zip_file.extractall(config.db.codebase_directory)
|
27 |
-
|
28 |
-
# Create and launch the chatbot
|
29 |
-
demo = create_chatbot(config)
|
30 |
-
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
|
|
|
|
|
1 |
from knowlang.chat_bot.chat_interface import create_chatbot
|
2 |
from knowlang.configs.config import AppConfig
|
|
|
|
|
3 |
|
|
|
4 |
|
5 |
+
config = AppConfig()
|
6 |
+
demo = create_chatbot(config)
|
7 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|