Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,7 +22,6 @@ def process_files(files):
|
|
| 22 |
global index, chunks
|
| 23 |
chunks = []
|
| 24 |
try:
|
| 25 |
-
# Gradio returns a list if multiple files are uploaded
|
| 26 |
if not isinstance(files, list):
|
| 27 |
files = [files]
|
| 28 |
|
|
@@ -64,7 +63,10 @@ def rag_pipeline(query, model_choice):
|
|
| 64 |
try:
|
| 65 |
response = client.chat.completions.create(
|
| 66 |
model=model_choice,
|
| 67 |
-
messages=[
|
|
|
|
|
|
|
|
|
|
| 68 |
)
|
| 69 |
answer = response.choices[0].message.content
|
| 70 |
chat_history.append((query, answer))
|
|
@@ -76,7 +78,6 @@ with gr.Blocks() as demo:
|
|
| 76 |
gr.Markdown("# π ContextPilot Bilal\n### Upload documents and ask optimized questions")
|
| 77 |
|
| 78 |
with gr.Tab("Upload Files"):
|
| 79 |
-
# β
Correct: use type="filepath" for file paths
|
| 80 |
file_input = gr.File(label="π Upload PDF or Text Files", file_types=[".pdf", ".txt"], type="filepath")
|
| 81 |
process_btn = gr.Button("π Process Files")
|
| 82 |
status_output = gr.Textbox(label="Status", interactive=False)
|
|
|
|
| 22 |
global index, chunks
|
| 23 |
chunks = []
|
| 24 |
try:
|
|
|
|
| 25 |
if not isinstance(files, list):
|
| 26 |
files = [files]
|
| 27 |
|
|
|
|
| 63 |
try:
|
| 64 |
response = client.chat.completions.create(
|
| 65 |
model=model_choice,
|
| 66 |
+
messages=[
|
| 67 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
| 68 |
+
{"role": "user", "content": prompt}
|
| 69 |
+
]
|
| 70 |
)
|
| 71 |
answer = response.choices[0].message.content
|
| 72 |
chat_history.append((query, answer))
|
|
|
|
| 78 |
gr.Markdown("# π ContextPilot Bilal\n### Upload documents and ask optimized questions")
|
| 79 |
|
| 80 |
with gr.Tab("Upload Files"):
|
|
|
|
| 81 |
file_input = gr.File(label="π Upload PDF or Text Files", file_types=[".pdf", ".txt"], type="filepath")
|
| 82 |
process_btn = gr.Button("π Process Files")
|
| 83 |
status_output = gr.Textbox(label="Status", interactive=False)
|