Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,7 +23,7 @@ def ask_chatbot(query, chat_history, project_data):
|
|
| 23 |
# Convert project_data to a string format (optional: simplify or summarize if needed)
|
| 24 |
project_data_str = json.dumps(project_data, indent=2)
|
| 25 |
|
| 26 |
-
if len(chat_history) >=
|
| 27 |
chat_history.pop(0)
|
| 28 |
|
| 29 |
query_with_history = ""
|
|
@@ -65,15 +65,25 @@ def generate_response(message, history):
|
|
| 65 |
def upload_file(data_file):
|
| 66 |
with open(data_file.name, "r") as f:
|
| 67 |
data = json.load(f)
|
| 68 |
-
gr.Info("
|
| 69 |
with open("/content/project_data.json", "w") as f:
|
| 70 |
json.dump(data, f)
|
| 71 |
|
| 72 |
with gr.Blocks() as demo:
|
| 73 |
-
|
| 74 |
u = gr.UploadButton("Upload a file", file_count="single")
|
| 75 |
u.upload(upload_file, u)
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
demo.launch()
|
| 79 |
|
|
|
|
| 23 |
# Convert project_data to a string format (optional: simplify or summarize if needed)
|
| 24 |
project_data_str = json.dumps(project_data, indent=2)
|
| 25 |
|
| 26 |
+
if len(chat_history) >= 10:
|
| 27 |
chat_history.pop(0)
|
| 28 |
|
| 29 |
query_with_history = ""
|
|
|
|
| 65 |
def upload_file(data_file):
|
| 66 |
with open(data_file.name, "r") as f:
|
| 67 |
data = json.load(f)
|
| 68 |
+
gr.Info("Project file Uploaded. You can now query the document")
|
| 69 |
with open("/content/project_data.json", "w") as f:
|
| 70 |
json.dump(data, f)
|
| 71 |
|
| 72 |
with gr.Blocks() as demo:
|
| 73 |
+
with gr.Column():
|
| 74 |
u = gr.UploadButton("Upload a file", file_count="single")
|
| 75 |
u.upload(upload_file, u)
|
| 76 |
+
gr.ChatInterface(
|
| 77 |
+
yes_man,
|
| 78 |
+
chatbot=gr.Chatbot(height=300),
|
| 79 |
+
title="AI Project Manager",
|
| 80 |
+
description="Virtual Project Management Assistant",
|
| 81 |
+
theme="soft",
|
| 82 |
+
examples=["Which task has the earliest deadline?", "What is the current progress?"],
|
| 83 |
+
cache_examples=True,
|
| 84 |
+
undo_btn="Delete Previous",
|
| 85 |
+
clear_btn="Clear",
|
| 86 |
+
)
|
| 87 |
|
| 88 |
demo.launch()
|
| 89 |
|