Skip to content

Commit

Permalink
update cli.
Browse files Browse the repository at this point in the history
  • Loading branch information
shibing624 committed Dec 31, 2024
1 parent ce056af commit d18b142
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
2 changes: 2 additions & 0 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
- **Solver**: The solver integrates all these outputs into the final answer

## 🔥 News
[2024/12/29] v0.2.3: Added support for `ZhipuAI` API calls, including free models and tool usage. See [Release-v0.2.3](https://github.com/shibing624/agentica/releases/tag/0.2.3)

[2024/12/25] v0.2.0 version: Supports multimodal models, input can be text, pictures, audio, video, upgrade Assistant to Agent, Workflow supports disassembly and implementation of complex tasks, see [Release-v0.2.0](https://github.com/shibing624/agentica/releases/tag/0.2.0)

[2024/07/02] v0.1.0 version: Implemented Assistant based on LLM, can quickly use function call to build a large language model assistant, see [Release-v0.1.0](https://github.com/shibing624/agentica/releases/tag/0.1.0)
Expand Down
30 changes: 16 additions & 14 deletions agentica/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import argparse
from rich.console import Console
from rich.text import Text
from agentica import Agent, OpenAIChat, MoonshotChat, AzureOpenAIChat, YiChat, ZhipuAIChat, DeepSeekChat
from agentica import Agent, OpenAIChat, MoonshotChat, AzureOpenAIChat, YiChat, ZhipuAIChat, DeepSeekChat, PythonAgent
from agentica.tools.search_serper_tool import SearchSerperTool
from agentica.tools.file_tool import FileTool
from agentica.tools.shell_tool import ShellTool
Expand All @@ -32,7 +32,7 @@ def parse_args():
parser.add_argument('--verbose', type=int, help='enable verbose mode', default=0)
parser.add_argument('--tools', nargs='*',
choices=['search_serper', 'file_tool', 'shell_tool', 'yfinance_tool', 'web_search_pro',
'cogview', 'cogvideo', 'jina', 'wikipedia'], help='Tools to enable')
'cogview', 'cogvideo', 'jina', 'wikipedia', 'python_tool'], help='Tools to enable')
return parser.parse_args()


Expand Down Expand Up @@ -100,18 +100,15 @@ def run_interactive(agent):
while True:
try:
if first_prompt:
console.print(Text("Enter your question (end with empty line, type 'exit' to quit):", style="green"))
console.print(Text("Enter your question (type 'exit' to quit):", style="green"))
console.print(Text(">>> ", style="green"), end="")
first_prompt = False
else:
console.print(Text(">>> ", style="green"), end="")
multi_line_input = []
while True:
line = console.input()
if line.strip() == "":
break
multi_line_input.append(line)
query = "\n".join(multi_line_input).strip()

line = console.input()
query = line.strip()

if query.lower() == 'exit':
break
if query:
Expand All @@ -133,11 +130,16 @@ def main():
api_key=args.api_key, max_tokens=args.max_tokens)
tools = configure_tools(args.tools) if args.tools else None
debug_mode = args.verbose > 0
agent = Agent(model=model, add_datetime_to_instructions=True, add_history_to_messages=True,
tools=tools, debug_mode=debug_mode)
if args.tools and 'python_tool' in args.tools:
agent = PythonAgent(model=model, add_datetime_to_instructions=True, add_history_to_messages=True,
tools=tools, debug_mode=debug_mode)
else:
agent = Agent(model=model, add_datetime_to_instructions=True, add_history_to_messages=True,
tools=tools, debug_mode=debug_mode)
if args.query:
result = agent.run(args.query).content
console.print(result)
response = agent.run(args.query, stream=True)
for chunk in response:
console.print(chunk.content, end="")
else:
run_interactive(agent)

Expand Down

0 comments on commit d18b142

Please sign in to comment.