Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -323,6 +323,10 @@ python_tool = PythonREPLTool()
|
|
| 323 |
tools.append(Tool(name="python_repl", func=python_tool.run, description="Python μ½λλ₯Ό μ€νν©λλ€."))
|
| 324 |
from langchain import hub
|
| 325 |
prompt=hub.pull("hwchase17/structured-chat-agent")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 326 |
# ββββββββββββββββββββββββββββββ
|
| 327 |
# β
νμΌ λꡬ
|
| 328 |
# ββββββββββββββββββββββββββββββ
|
|
@@ -373,12 +377,16 @@ agent=initialize_agent(tools,llm,agent=AgentType.OPENAI_MULTI_FUNCTIONS,verbose=
|
|
| 373 |
# ββββββββββββββββββββββββββββββ
|
| 374 |
def chat(message, history):
|
| 375 |
try:
|
| 376 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 377 |
except Exception as e:
|
| 378 |
response = f"β οΈ μ€λ₯: {e}"
|
| 379 |
-
history
|
| 380 |
-
return history,history
|
| 381 |
-
|
| 382 |
with gr.Blocks(theme=gr.themes.Soft(), title="PIXAL Assistant (LangChain + GitHub LLM)") as demo:
|
| 383 |
gr.Markdown("""
|
| 384 |
## π€ PIXAL Assistant
|
|
|
|
| 323 |
tools.append(Tool(name="python_repl", func=python_tool.run, description="Python μ½λλ₯Ό μ€νν©λλ€."))
|
| 324 |
from langchain import hub
|
| 325 |
prompt=hub.pull("hwchase17/structured-chat-agent")
|
| 326 |
+
from langchain_experimental.tools.shell.tool import ShellTool
|
| 327 |
+
shell_tool = ShellTool()
|
| 328 |
+
tools.append(Tool(name="shell_exec", func=shell_tool.run, description="λ‘컬 λͺ
λ Ήμ΄λ₯Ό μ€νν©λλ€."))
|
| 329 |
+
|
| 330 |
# ββββββββββββββββββββββββββββββ
|
| 331 |
# β
νμΌ λꡬ
|
| 332 |
# ββββββββββββββββββββββββββββββ
|
|
|
|
| 377 |
# ββββββββββββββββββββββββββββββ
|
| 378 |
def chat(message, history):
|
| 379 |
try:
|
| 380 |
+
result = agent.invoke(message)
|
| 381 |
+
# dict λμ μ²λ¦¬
|
| 382 |
+
if isinstance(result, dict):
|
| 383 |
+
response = result.get("output") or result.get("answer") or str(result)
|
| 384 |
+
else:
|
| 385 |
+
response = str(result)
|
| 386 |
except Exception as e:
|
| 387 |
response = f"β οΈ μ€λ₯: {e}"
|
| 388 |
+
history.append((message, response))
|
| 389 |
+
return history, history
|
|
|
|
| 390 |
with gr.Blocks(theme=gr.themes.Soft(), title="PIXAL Assistant (LangChain + GitHub LLM)") as demo:
|
| 391 |
gr.Markdown("""
|
| 392 |
## π€ PIXAL Assistant
|