Update app.py
Browse filesAdd debug prints.
app.py
CHANGED
@@ -22,14 +22,19 @@ class LocalLLM:
|
|
22 |
def generate(self, prompt, **kwargs):
|
23 |
unsupported_keys = ["stop_sequences"] # Remove keys not accepted by HF pipelines
|
24 |
cleaned_kwargs = {k: v for k, v in kwargs.items() if k not in unsupported_keys}
|
|
|
25 |
try:
|
26 |
outputs = self.pipe(prompt, **cleaned_kwargs)
|
27 |
# outputs = [{'generated_text': '...'}]
|
|
|
28 |
if isinstance(outputs, list) and isinstance(outputs[0], dict):
|
29 |
-
|
30 |
elif isinstance(outputs, list):
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
33 |
except Exception as e:
|
34 |
print(f"❌ Error in LocalLLM.generate(): {e}")
|
35 |
raise
|
@@ -281,5 +286,9 @@ if __name__ == "__main__":
|
|
281 |
|
282 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
283 |
|
|
|
|
|
|
|
|
|
284 |
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
285 |
demo.launch(debug=True, share=False)
|
|
|
22 |
def generate(self, prompt, **kwargs):
|
23 |
unsupported_keys = ["stop_sequences"] # Remove keys not accepted by HF pipelines
|
24 |
cleaned_kwargs = {k: v for k, v in kwargs.items() if k not in unsupported_keys}
|
25 |
+
print(f"🧪 kwargs cleaned: {cleaned_kwargs.keys()}")
|
26 |
try:
|
27 |
outputs = self.pipe(prompt, **cleaned_kwargs)
|
28 |
# outputs = [{'generated_text': '...'}]
|
29 |
+
print(f"🧪 Raw output from pipe: {outputs}")
|
30 |
if isinstance(outputs, list) and isinstance(outputs[0], dict):
|
31 |
+
out = outputs[0]["generated_text"]
|
32 |
elif isinstance(outputs, list):
|
33 |
+
out = outputs[0] # fallback if it's just a list of strings
|
34 |
+
else:
|
35 |
+
out = str(outputs)
|
36 |
+
print(f"🧪 Final output string: {out[:100]}")
|
37 |
+
return out
|
38 |
except Exception as e:
|
39 |
print(f"❌ Error in LocalLLM.generate(): {e}")
|
40 |
raise
|
|
|
286 |
|
287 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
288 |
|
289 |
+
# Test the agent
|
290 |
+
agent = BasicAgent()
|
291 |
+
print("TEST OUTPUT:", agent.model.generate("What is 2+2?"))
|
292 |
+
|
293 |
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
294 |
demo.launch(debug=True, share=False)
|