peterpeter8585 commited on
Commit
a07a1e4
Β·
verified Β·
1 Parent(s): 5d93a81

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
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
- response = agent.invoke(message)
 
 
 
 
 
377
  except Exception as e:
378
  response = f"⚠️ 였λ₯˜: {e}"
379
- history = history + [(message, response)]
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