Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
-
import transformers
|
3 |
|
4 |
# Load your custom models (example)
|
5 |
model_name = "microsoft/Phi-3-mini-4k-instruct" # Replace with your model name
|
@@ -12,9 +12,10 @@ def chatbot_response(user_input):
|
|
12 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
13 |
return response
|
14 |
|
15 |
-
def upload_readme(
|
16 |
-
if
|
17 |
-
|
|
|
18 |
return content
|
19 |
return "No file uploaded"
|
20 |
|
@@ -28,14 +29,14 @@ with gr.Blocks() as demo:
|
|
28 |
readme_file = gr.File(label="Upload README file", type="filepath", file_types=[".md"])
|
29 |
readme_content = gr.Textbox(label="README Content", lines=10, placeholder="README content will appear here...")
|
30 |
|
31 |
-
#
|
32 |
readme_file.change(upload_readme, inputs=readme_file, outputs=readme_content)
|
33 |
|
34 |
# Chatbot input and output
|
35 |
user_input = gr.Textbox(label="Your message", placeholder="Type your message here...")
|
36 |
output = gr.Textbox(label="Chatbot response", placeholder="Chatbot response will appear here...", lines=5)
|
37 |
|
38 |
-
#
|
39 |
user_input.submit(chatbot_response, inputs=user_input, outputs=output)
|
40 |
|
41 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import transformers
|
3 |
|
4 |
# Load your custom models (example)
|
5 |
model_name = "microsoft/Phi-3-mini-4k-instruct" # Replace with your model name
|
|
|
12 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
13 |
return response
|
14 |
|
15 |
+
def upload_readme(filepath):
|
16 |
+
if filepath is not None:
|
17 |
+
with open(filepath, 'r', encoding='utf-8') as file:
|
18 |
+
content = file.read()
|
19 |
return content
|
20 |
return "No file uploaded"
|
21 |
|
|
|
29 |
readme_file = gr.File(label="Upload README file", type="filepath", file_types=[".md"])
|
30 |
readme_content = gr.Textbox(label="README Content", lines=10, placeholder="README content will appear here...")
|
31 |
|
32 |
+
# Display README content after upload
|
33 |
readme_file.change(upload_readme, inputs=readme_file, outputs=readme_content)
|
34 |
|
35 |
# Chatbot input and output
|
36 |
user_input = gr.Textbox(label="Your message", placeholder="Type your message here...")
|
37 |
output = gr.Textbox(label="Chatbot response", placeholder="Chatbot response will appear here...", lines=5)
|
38 |
|
39 |
+
# Get chatbot response
|
40 |
user_input.submit(chatbot_response, inputs=user_input, outputs=output)
|
41 |
|
42 |
demo.launch()
|