Skip to content

Commit

Permalink
added MarkDown flag for node. Can print in MarkDown instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Holmeswww committed Oct 9, 2024
1 parent afd8704 commit b52bdab
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ To support advanced capabilities such as branching, AgentKit offers API to dynam

# Citing AgentKit
```bibtex
@article{wu2024agentkit,
title={AgentKit: Flow Engineering with Graphs, not Coding},
author={Yue Wu and Yewen Fan and So Yeon Min and Shrimai Prabhumoye and Stephen McAleer and Yonatan Bisk and Ruslan Salakhutdinov and Yuanzhi Li and Tom Mitchell},
year={2024},
journal={arXiv preprint arXiv:2404.11483}
@inproceedings{agentkit,
title = {AgentKit: Flow Engineering with Graphs, not Coding},
author = {Wu, Yue and Fan, Yewen and Min, So Yeon and Prabhumoye, Shrimai and McAleer, Stephen and Bisk, Yonatan and Salakhutdinov, Ruslan and Li, Yuanzhi and Mitchell, Tom},
year = {2024},
booktitle = {COLM},
}
```

Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
author = 'Yue Wu'

release = '0.1'
version = '0.1.8'
version = '0.1.8.1'

# -- General configuration

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pathlib

PKG_NAME = "agentkit-llm"
VERSION = "0.1.8"
VERSION = "0.1.8.1"
EXTRAS = {
"logging": ["wandb"],
"proprietary": ["wandb", "openai", "anthropic", "tiktoken"],
Expand Down
16 changes: 13 additions & 3 deletions src/agentkit/base_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def __init__(self, key:str, prompt:str, graph:Graph, query_llm:Callable, compose
self.after_query = after_query
self.after_query.set_node(self)
self.verbose = verbose
self.markdown = False
self._add_error_msg = error_msg_fn

if token_counter is not None:
Expand Down Expand Up @@ -94,15 +95,24 @@ def compose_prompt(self):

def _print_question(self):
if self.verbose:
print(Fore.CYAN + "Prompt: " + Style.DIM + "{}".format(self.prompt) + Style.RESET_ALL)
if self.markdown:
print("\n### Prompt\n" + "<span style='color:green;'>\n{}\n</span>".format(self.prompt))
else:
print(Fore.CYAN + "Prompt: " + Style.DIM + "{}".format(self.prompt) + Style.RESET_ALL)

def _print_answer(self, msg):
if self.verbose:
print("Answer: " + Style.DIM + "{}".format(msg) + Style.RESET_ALL)
if self.markdown:
print("\n#### Answer\n" + "<span style='color: #d7dbdd;'>\n{}\n</span>".format(msg))
else:
print("Answer: " + Style.DIM + "{}".format(msg) + Style.RESET_ALL)

def _print_skip(self):
if self.verbose:
print("Skip: " + Style.DIM + "{}".format(self.prompt) + Style.RESET_ALL)
if self.markdown:
print("\n### Skip\n" + "{}".format(self.prompt))
else:
print("Skip: " + Style.DIM + "{}".format(self.prompt) + Style.RESET_ALL)

def skip_turn(self):
"""Temporarily skip the node evaluation. The previous result of the node will be reused.
Expand Down
10 changes: 8 additions & 2 deletions src/agentkit/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,11 @@ def compose_prompt(self):
def _print_answer(self, msg):
if self.verbose:
if hasattr(self, 'db_retrieval_results') and len(self.db_retrieval_results) > 0:
print("DB operations: " + Style.DIM + Fore.BLUE + "{}".format(self.db_retrieval_results) + Style.RESET_ALL)
print("Answer: " + Style.DIM + "{}".format(msg) + Style.RESET_ALL)
if self.markdown:
print(f"\n##### DB operations\n<span style='color: #76d7c4;'>\n{self.db_retrieval_results}\n</span>")
else:
print("DB operations: " + Style.DIM + Fore.BLUE + "{}".format(self.db_retrieval_results) + Style.RESET_ALL)
if self.markdown:
print("\n#### Answer\n<span style='color: #d7dbdd;'>\n{}\n</span>".format(msg))
else:
print("Answer: " + Style.DIM + "{}".format(msg) + Style.RESET_ALL)

0 comments on commit b52bdab

Please sign in to comment.