Update app.py
Browse files
app.py
CHANGED
@@ -34,14 +34,22 @@ class GAIAAgent:
|
|
34 |
filepath = os.path.join("./", filename)
|
35 |
if filename.endswith(".txt") and os.path.exists(filepath):
|
36 |
with open(filepath, "r") as file:
|
37 |
-
return file.read()[:1000]
|
38 |
return ""
|
39 |
|
40 |
def __call__(self, question: str, file_name: str = None) -> str:
|
41 |
file_content = self.read_file(file_name) if file_name else None
|
42 |
prompt = self.format_prompt(question, file_content)
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
|
47 |
def run_and_submit_all(profile: gr.OAuthProfile | None):
|
@@ -127,4 +135,4 @@ with gr.Blocks() as demo:
|
|
127 |
|
128 |
if __name__ == "__main__":
|
129 |
print("Launching GAIA agent app...")
|
130 |
-
demo.launch(debug=True, share=False)
|
|
|
34 |
filepath = os.path.join("./", filename)
|
35 |
if filename.endswith(".txt") and os.path.exists(filepath):
|
36 |
with open(filepath, "r") as file:
|
37 |
+
return file.read()[:1000] # limit to 1000 chars
|
38 |
return ""
|
39 |
|
40 |
def __call__(self, question: str, file_name: str = None) -> str:
|
41 |
file_content = self.read_file(file_name) if file_name else None
|
42 |
prompt = self.format_prompt(question, file_content)
|
43 |
+
try:
|
44 |
+
print("Prompt sent to model:", prompt)
|
45 |
+
result = self.model(prompt)
|
46 |
+
print("Model raw result:", result)
|
47 |
+
if not result or not isinstance(result, str):
|
48 |
+
return "AGENT ERROR: Empty or invalid response"
|
49 |
+
return result.strip().split("Answer:")[-1].strip()
|
50 |
+
except Exception as e:
|
51 |
+
print(f"Model inference failed: {e}")
|
52 |
+
return f"AGENT ERROR: {e}"
|
53 |
|
54 |
|
55 |
def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
|
135 |
|
136 |
if __name__ == "__main__":
|
137 |
print("Launching GAIA agent app...")
|
138 |
+
demo.launch(debug=True, share=False)
|