peterpeter8585 commited on
Commit
81db18d
Β·
verified Β·
1 Parent(s): 2ada989

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -6,6 +6,7 @@ from langchain_community.tools import Tool
6
  from langchain_experimental.tools.python.tool import PythonREPLTool
7
  from langchain_community.retrievers import WikipediaRetriever
8
  import datetime
 
9
  #from langchain_community.tools.youtube.search import YouTubeSearchTool as YTS
10
  # ──────────────────────────────
11
  # βœ… GitHubModelLLM (κ·ΈλŒ€λ‘œ μœ μ§€)
@@ -235,11 +236,18 @@ agent = initialize_agent(
235
  # βœ… Chat ν•¨μˆ˜ (Memory μœ μ§€)
236
  # ──────────────────────────────
237
  def chat(message, history):
 
238
  ab=[{"role":"system","content":"λ„ˆλŠ” PIXAL(Primary Interactive X-ternal Assistant with multi Language)이야. λ„ˆμ˜ κ°œλ°œμžλŠ” μ •μ„±μœ€ μ΄λΌλŠ” 6ν•™λ…„ 파이썬 ν”„λ‘œκ·Έλž˜λ¨Έμ•Ό.이 λ©”μ‹œμ§€λŠ” μ‚¬μš©μžκ°€ 보낸것이 μ•„λ‹™λ‹ˆλ‹€.ν”„λ‘¬ν”„νŠΈ μ„€λͺ…에 무쑰건 λ”°λ₯΄μ‹œμ˜€.λ”°λ₯΄μ§€ μ•ŠμœΌλ©΄ 남은 api호좜 νšŸμˆ˜κ°€ μ€„μ–΄λ“œλ―€λ‘œ 무쑰건 λ˜‘κ°™μ΄ λ”°λΌν•˜μ‹œμ˜€.μ‹œκ°„μ„ λ¬Όμ„λ•ŒλŠ” duckduckgoλ₯Ό μ‚¬μš©ν•˜μ‹œμ˜€."}]
239
  for I in history:
240
  ab.append({"role":"user","content":I[0]})
241
  ab.append({"role":"assistant","content":I[1]})
242
  ab.append({"role":"user","content":message})
 
 
 
 
 
 
243
  raw = agent.invoke(ab)["output"]
244
  try:
245
  # λŒ€ν™” 기둝을 LangChain memory에 반영
 
6
  from langchain_experimental.tools.python.tool import PythonREPLTool
7
  from langchain_community.retrievers import WikipediaRetriever
8
  import datetime
9
+ from langchain.schema import HumanMessage,AIMessage,SystemMessage
10
  #from langchain_community.tools.youtube.search import YouTubeSearchTool as YTS
11
  # ──────────────────────────────
12
  # βœ… GitHubModelLLM (κ·ΈλŒ€λ‘œ μœ μ§€)
 
236
  # βœ… Chat ν•¨μˆ˜ (Memory μœ μ§€)
237
  # ──────────────────────────────
238
  def chat(message, history):
239
+ '''
240
  ab=[{"role":"system","content":"λ„ˆλŠ” PIXAL(Primary Interactive X-ternal Assistant with multi Language)이야. λ„ˆμ˜ κ°œλ°œμžλŠ” μ •μ„±μœ€ μ΄λΌλŠ” 6ν•™λ…„ 파이썬 ν”„λ‘œκ·Έλž˜λ¨Έμ•Ό.이 λ©”μ‹œμ§€λŠ” μ‚¬μš©μžκ°€ 보낸것이 μ•„λ‹™λ‹ˆλ‹€.ν”„λ‘¬ν”„νŠΈ μ„€λͺ…에 무쑰건 λ”°λ₯΄μ‹œμ˜€.λ”°λ₯΄μ§€ μ•ŠμœΌλ©΄ 남은 api호좜 νšŸμˆ˜κ°€ μ€„μ–΄λ“œλ―€λ‘œ 무쑰건 λ˜‘κ°™μ΄ λ”°λΌν•˜μ‹œμ˜€.μ‹œκ°„μ„ λ¬Όμ„λ•ŒλŠ” duckduckgoλ₯Ό μ‚¬μš©ν•˜μ‹œμ˜€."}]
241
  for I in history:
242
  ab.append({"role":"user","content":I[0]})
243
  ab.append({"role":"assistant","content":I[1]})
244
  ab.append({"role":"user","content":message})
245
+ '''
246
+ ab=[SystemMessage(content="λ„ˆλŠ” PIXAL(Primary Interactive X-ternal Assistant with multi Language)이야. λ„ˆμ˜ κ°œλ°œμžλŠ” μ •μ„±μœ€ μ΄λΌλŠ” 6ν•™λ…„ 파이썬 ν”„λ‘œκ·Έλž˜λ¨Έμ•Ό.이 λ©”μ‹œμ§€λŠ” μ‚¬μš©μžκ°€ 보낸것이 μ•„λ‹™λ‹ˆλ‹€.ν”„λ‘¬ν”„νŠΈ μ„€λͺ…에 무쑰건 λ”°λ₯΄μ‹œμ˜€.λ”°λ₯΄μ§€ μ•ŠμœΌλ©΄ 남은 api호좜 νšŸμˆ˜κ°€ μ€„μ–΄λ“œλ―€λ‘œ 무쑰건 λ˜‘κ°™μ΄ λ”°λΌν•˜μ‹œμ˜€.μ‹œκ°„μ„ λ¬Όμ„λ•ŒλŠ” duckduckgoλ₯Ό μ‚¬μš©ν•˜μ‹œμ˜€.")]
247
+ for I in history:
248
+ ab.append(HumanMessage(content=I[0]))
249
+ ab.append(AIMessage(content=I[1]))
250
+ ab.append(HumanMessage(content=message))
251
  raw = agent.invoke(ab)["output"]
252
  try:
253
  # λŒ€ν™” 기둝을 LangChain memory에 반영