Spaces:
Sleeping
Sleeping
camparchimedes
commited on
Commit
•
8272aaf
1
Parent(s):
e1f6cb1
Update app.py
Browse files
app.py
CHANGED
@@ -32,17 +32,18 @@ def respond(
|
|
32 |
stream=True,
|
33 |
temperature=temperature,
|
34 |
top_p=top_p,
|
|
|
35 |
):
|
36 |
token = message.choices[0].delta.content
|
37 |
|
38 |
response += token
|
39 |
yield response
|
40 |
|
41 |
-
# Process
|
42 |
if uploaded_file is not None:
|
43 |
print(f"Uploaded file: {uploaded_file.name}")
|
44 |
|
45 |
-
# Process
|
46 |
if uploaded_file.name.endswith(".csv"):
|
47 |
try:
|
48 |
df = pd.read_csv(uploaded_file.name)
|
@@ -54,7 +55,7 @@ def respond(
|
|
54 |
except Exception as e:
|
55 |
print(f"Error loading CSV file: {e}")
|
56 |
|
57 |
-
# Process
|
58 |
elif uploaded_file.name.endswith(".txt"):
|
59 |
try:
|
60 |
with open(uploaded_file.name, "r") as f:
|
@@ -67,8 +68,7 @@ def respond(
|
|
67 |
except Exception as e:
|
68 |
print(f"Error loading text file: {e}")
|
69 |
|
70 |
-
# Add more
|
71 |
-
|
72 |
"""
|
73 |
For information on how to customize the ChatInterface: https://www.gradio.app/docs/chatinterface
|
74 |
"""
|
@@ -90,5 +90,5 @@ demo = gr.ChatInterface(
|
|
90 |
)
|
91 |
|
92 |
if __name__ == "__main__":
|
93 |
-
demo.launch()
|
94 |
|
|
|
32 |
stream=True,
|
33 |
temperature=temperature,
|
34 |
top_p=top_p,
|
35 |
+
uploaded_file = uploaded_file,
|
36 |
):
|
37 |
token = message.choices[0].delta.content
|
38 |
|
39 |
response += token
|
40 |
yield response
|
41 |
|
42 |
+
# Process
|
43 |
if uploaded_file is not None:
|
44 |
print(f"Uploaded file: {uploaded_file.name}")
|
45 |
|
46 |
+
# Process CSV
|
47 |
if uploaded_file.name.endswith(".csv"):
|
48 |
try:
|
49 |
df = pd.read_csv(uploaded_file.name)
|
|
|
55 |
except Exception as e:
|
56 |
print(f"Error loading CSV file: {e}")
|
57 |
|
58 |
+
# Process text
|
59 |
elif uploaded_file.name.endswith(".txt"):
|
60 |
try:
|
61 |
with open(uploaded_file.name, "r") as f:
|
|
|
68 |
except Exception as e:
|
69 |
print(f"Error loading text file: {e}")
|
70 |
|
71 |
+
# Add more ? shit doesn't work
|
|
|
72 |
"""
|
73 |
For information on how to customize the ChatInterface: https://www.gradio.app/docs/chatinterface
|
74 |
"""
|
|
|
90 |
)
|
91 |
|
92 |
if __name__ == "__main__":
|
93 |
+
demo.launch(share=True, debug=True)
|
94 |
|