Update app.py
Browse files
app.py
CHANGED
@@ -22,18 +22,17 @@ 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 |
-
print(f"🧪 kwargs cleaned: {cleaned_kwargs.keys()}")
|
26 |
try:
|
27 |
outputs = self.pipe(prompt, **cleaned_kwargs)
|
28 |
-
#
|
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}")
|
@@ -71,7 +70,7 @@ def check_token_access():
|
|
71 |
print("❌ Token check failed:", e)
|
72 |
|
73 |
# --- Basic Agent Definition ---
|
74 |
-
# ----- THIS IS
|
75 |
class BasicAgent:
|
76 |
def __init__(self):
|
77 |
print("BasicAgent initialized.")
|
@@ -286,9 +285,5 @@ if __name__ == "__main__":
|
|
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)
|
|
|
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 |
+
# print(f"🧪 Raw output from pipe: {outputs}")
|
|
|
29 |
if isinstance(outputs, list) and isinstance(outputs[0], dict):
|
30 |
out = outputs[0]["generated_text"]
|
31 |
elif isinstance(outputs, list):
|
32 |
out = outputs[0] # fallback if it's just a list of strings
|
33 |
else:
|
34 |
out = str(outputs)
|
35 |
+
# print(f"🧪 Final output string: {out[:100]}")
|
36 |
return out
|
37 |
except Exception as e:
|
38 |
print(f"❌ Error in LocalLLM.generate(): {e}")
|
|
|
70 |
print("❌ Token check failed:", e)
|
71 |
|
72 |
# --- Basic Agent Definition ---
|
73 |
+
# ----- THIS IS WHERE YOU CAN BUILD WHAT YOU WANT ------
|
74 |
class BasicAgent:
|
75 |
def __init__(self):
|
76 |
print("BasicAgent initialized.")
|
|
|
285 |
|
286 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
287 |
|
|
|
|
|
|
|
|
|
288 |
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
289 |
demo.launch(debug=True, share=False)
|