Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,20 +5,20 @@ from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
5 |
import gradio as gr
|
6 |
import os
|
7 |
import logging
|
8 |
-
|
9 |
import subprocess
|
10 |
|
11 |
-
# Set up logging
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
logger = logging.getLogger(__name__)
|
13 |
-
logger.setLevel(logging.DEBUG) # Set the logging level
|
14 |
-
ch = logging.StreamHandler(gr.Log()) # Create a StreamHandler and send logs to gr.Log
|
15 |
-
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
16 |
-
ch.setFormatter(formatter)
|
17 |
-
logger.addHandler(ch)
|
18 |
|
19 |
# Get environment variable for Hugging Face access
|
20 |
-
READ_HF = os.environ.get("read_hf")
|
21 |
-
logger.info("Checking logger...")
|
22 |
# Alpaca prompt template
|
23 |
alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
24 |
|
@@ -140,6 +140,22 @@ iface = gr.Interface(
|
|
140 |
],
|
141 |
outputs=gr.Textbox(label="output", lines=23),
|
142 |
title="Testing",
|
|
|
143 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
|
145 |
iface.launch(inline=False)
|
|
|
5 |
import gradio as gr
|
6 |
import os
|
7 |
import logging
|
8 |
+
from unsloth import FastLanguageModel
|
9 |
import subprocess
|
10 |
|
11 |
+
# Set up logging to file
|
12 |
+
log_file_path = "app.log" # Name of your log file
|
13 |
+
logging.basicConfig(
|
14 |
+
filename=log_file_path,
|
15 |
+
level=logging.DEBUG,
|
16 |
+
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
17 |
+
)
|
18 |
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
# Get environment variable for Hugging Face access
|
21 |
+
READ_HF = os.environ.get("read_hf")
|
|
|
22 |
# Alpaca prompt template
|
23 |
alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
24 |
|
|
|
140 |
],
|
141 |
outputs=gr.Textbox(label="output", lines=23),
|
142 |
title="Testing",
|
143 |
+
allow_flagging="manual",
|
144 |
)
|
145 |
+
# --- Code to commit the log file to your repo ---
|
146 |
+
try:
|
147 |
+
# Add the log file to the git staging area
|
148 |
+
subprocess.run(['git', 'add', log_file_path])
|
149 |
+
|
150 |
+
# Commit the changes
|
151 |
+
subprocess.run(['git', 'commit', '-m', 'Update log file'])
|
152 |
+
|
153 |
+
# Push the changes to the remote repository (usually 'origin')
|
154 |
+
subprocess.run(['git', 'push'])
|
155 |
+
|
156 |
+
logger.info("Log file committed to the repository.")
|
157 |
+
|
158 |
+
except Exception as e:
|
159 |
+
logger.error(f"Error committing log file: {e}")
|
160 |
|
161 |
iface.launch(inline=False)
|