Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -37,8 +37,7 @@ def write_article(topic: str, search_results: str) -> str:
|
|
37 |
작성된 기사
|
38 |
"""
|
39 |
try:
|
40 |
-
system_prompt = """
|
41 |
-
당신은 전문 기자입니다. 주어진 주제에 대해 검색된 정보를 바탕으로 새로운 기사를 한국어로 작성해야 합니다.
|
42 |
다음 형식으로 기사를 작성해주세요:
|
43 |
|
44 |
1. 제목 (흥미롭고 눈에 띄는 제목)
|
@@ -46,20 +45,29 @@ def write_article(topic: str, search_results: str) -> str:
|
|
46 |
3. 본문 (상세한 내용을 단락으로 구분하여 작성)
|
47 |
4. 결론 (기사의 의의나 향후 전망)
|
48 |
|
49 |
-
기사는 객관적이고 사실에 기반하여 작성해야 하며, 검색된 정보를 재구성하여 새로운 시각으로 작성해주세요.
|
50 |
-
"""
|
51 |
|
52 |
-
|
53 |
-
다음 주제와 검색 결과를 바탕으로 새로운 기사를 한국어로 작성해주세요:
|
54 |
|
55 |
주제: {topic}
|
56 |
|
57 |
검색 결과:
|
58 |
{search_results}
|
59 |
|
60 |
-
위 정보를 바탕으로 새롭고 통찰력 있는 기사를
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
except Exception as e:
|
64 |
traceback.print_exc()
|
65 |
return f"기사 작성 중 오류 발생: {str(e)}"
|
@@ -79,7 +87,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
79 |
agent = CodeAgent(
|
80 |
model=model,
|
81 |
tools=[search_news, write_article, final_answer],
|
82 |
-
max_steps=
|
83 |
verbosity_level=1,
|
84 |
grammar=None,
|
85 |
planning_interval=None,
|
|
|
37 |
작성된 기사
|
38 |
"""
|
39 |
try:
|
40 |
+
system_prompt = """당신은 전문 기자입니다. 주어진 주제에 대해 검색된 정보를 바탕으로 새로운 기사를 한국어로 작성해야 합니다.
|
|
|
41 |
다음 형식으로 기사를 작성해주세요:
|
42 |
|
43 |
1. 제목 (흥미롭고 눈에 띄는 제목)
|
|
|
45 |
3. 본문 (상세한 내용을 단락으로 구분하여 작성)
|
46 |
4. 결론 (기사의 의의나 향후 전망)
|
47 |
|
48 |
+
기사는 객관적이고 사실에 기반하여 작성해야 하며, 검색된 정보를 재구성하여 새로운 시각으로 작성해주세요."""
|
|
|
49 |
|
50 |
+
user_prompt = f"""다음 주제와 검색 결과를 바탕으로 새로운 기사를 한국어로 작성해주세요:
|
|
|
51 |
|
52 |
주제: {topic}
|
53 |
|
54 |
검색 결과:
|
55 |
{search_results}
|
56 |
|
57 |
+
위 정보를 바탕으로 새롭고 통찰력 있는 기사를 작성해주세요."""
|
58 |
+
|
59 |
+
messages = [
|
60 |
+
{"role": "system", "content": system_prompt},
|
61 |
+
{"role": "user", "content": user_prompt}
|
62 |
+
]
|
63 |
+
|
64 |
+
response = model(messages)
|
65 |
+
if isinstance(response, dict) and 'content' in response:
|
66 |
+
return response['content']
|
67 |
+
elif hasattr(response, 'content'):
|
68 |
+
return response.content
|
69 |
+
else:
|
70 |
+
return str(response)
|
71 |
except Exception as e:
|
72 |
traceback.print_exc()
|
73 |
return f"기사 작성 중 오류 발생: {str(e)}"
|
|
|
87 |
agent = CodeAgent(
|
88 |
model=model,
|
89 |
tools=[search_news, write_article, final_answer],
|
90 |
+
max_steps=10,
|
91 |
verbosity_level=1,
|
92 |
grammar=None,
|
93 |
planning_interval=None,
|