File size: 1,036 Bytes
70bd9e5
 
 
1d034b2
 
70bd9e5
 
1d034b2
70bd9e5
1d034b2
70bd9e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8523f06
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import requests
import zipfile
import io
from know_lang_bot.chat_bot.chat_interface import create_chatbot
from know_lang_bot.config import AppConfig
import tempfile
from rich.console import Console

console = Console()

# gradio demo
with tempfile.TemporaryDirectory() as temp_dir:
    config = AppConfig()
    with console.status("Downloading and extracting codebase...") as status:
        config.db.codebase_directory = temp_dir
        status.update(f"Downloading codebase into {temp_dir}...\n")
        

        # Download and unzip the code
        url = "https://github.com/huggingface/transformers/archive/refs/tags/v4.48.1.zip"
        response = requests.get(url)
        zip_file = zipfile.ZipFile(io.BytesIO(response.content))
        status.update(f"Extracting codebase...\n")

        # Extract the zip file into the codebase directory
        zip_file.extractall(config.db.codebase_directory)

    # Create and launch the chatbot
    demo = create_chatbot(config)
    demo.launch(server_name="0.0.0.0", server_port=7860)