* added log tab
* added references text box * added options to choose embedding models
This commit is contained in:
parent
eedbb1b81a
commit
18f35b28c2
42 changed files with 911 additions and 441 deletions
|
@ -1,3 +1,47 @@
|
|||
import os
|
||||
print("---")
|
||||
print(os.getcwd())
|
||||
import gradio as gr
|
||||
import sys
|
||||
|
||||
|
||||
class Logger:
|
||||
def __init__(self, filename):
|
||||
self.terminal = sys.stdout
|
||||
self.log = open(filename, "w")
|
||||
|
||||
def write(self, message):
|
||||
self.terminal.write(message)
|
||||
self.log.write(message)
|
||||
|
||||
def flush(self):
|
||||
self.terminal.flush()
|
||||
self.log.flush()
|
||||
|
||||
def isatty(self):
|
||||
return False
|
||||
|
||||
|
||||
sys.stdout = Logger("../temp_file/output.log")
|
||||
|
||||
|
||||
def test(x):
|
||||
print("This is a test")
|
||||
print(f"Your function is running with input {x}...")
|
||||
return x
|
||||
|
||||
|
||||
def read_logs():
|
||||
sys.stdout.flush()
|
||||
with open("../temp_file/output.log", "r") as f:
|
||||
return f.read()
|
||||
|
||||
|
||||
with gr.Blocks() as demo:
|
||||
with gr.Row():
|
||||
input = gr.Textbox()
|
||||
output = gr.Textbox()
|
||||
btn = gr.Button("Run")
|
||||
btn.click(test, input, output)
|
||||
|
||||
logs = gr.Textbox()
|
||||
demo.load(read_logs, None, logs, every=1)
|
||||
|
||||
demo.queue().launch()
|
Loading…
Add table
Add a link
Reference in a new issue