Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
aniketmaurya committed May 6, 2024
1 parent f74adc1 commit 870788d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 188 deletions.
7 changes: 5 additions & 2 deletions src/agents/awesome.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from hermes.functioncall import ModelInference

model_inference = ModelInference(chat_template="chatml")
# model_path = 'NousResearch/Hermes-2-Pro-Llama-3-8B'
model_path = "/Users/aniket/weights/llama-cpp/Hermes-2-Pro-Llama-3-8B-Q8_0.gguf"

model_inference = ModelInference(model_path=model_path, )
model_inference.generate_function_call(
"When was Golden Gate bridge last painted?", None, 5
"Fetch the stock fundamentals data for Tesla (TSLA)", None, 2
)
171 changes: 0 additions & 171 deletions src/agents/hermes/functioncall.py

This file was deleted.

24 changes: 13 additions & 11 deletions src/agents/hermes/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from typing import List
from bs4 import BeautifulSoup
from langchain_community.tools import DuckDuckGoSearchRun
from .utils import inference_logger
from langchain.tools import tool
from langchain_core.utils.function_calling import convert_to_openai_tool
Expand Down Expand Up @@ -339,17 +340,18 @@ def get_company_profile(symbol: str) -> dict:

def get_openai_tools() -> List[dict]:
functions = [
code_interpreter,
google_search_and_scrape,
get_current_stock_price,
get_company_news,
get_company_profile,
get_stock_fundamentals,
get_financial_statements,
get_key_financial_ratios,
get_analyst_recommendations,
get_dividend_data,
get_technical_indicators
# code_interpreter,
# google_search_and_scrape,
# get_current_stock_price,
# get_company_news,
# get_company_profile,
# get_stock_fundamentals,
# get_financial_statements,
# get_key_financial_ratios,
# get_analyst_recommendations,
# get_dividend_data,
# get_technical_indicators,
DuckDuckGoSearchRun()
]

tools = [convert_to_openai_tool(f) for f in functions]
Expand Down
6 changes: 2 additions & 4 deletions src/agents/hermes/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from art import text2art
from logging.handlers import RotatingFileHandler

from tqdm.auto import tqdm

logging.basicConfig(
format="%(asctime)s,%(msecs)03d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s",
Expand All @@ -20,7 +19,7 @@
)
script_dir = os.path.dirname(os.path.abspath(__file__))
now = datetime.datetime.now()
log_folder = os.path.join(script_dir, "inference_logs")
log_folder = os.path.join(os.path.curdir, "inference_logs")
os.makedirs(log_folder, exist_ok=True)
log_file_path = os.path.join(
log_folder, f"function-calling-inference_{now.strftime('%Y-%m-%d_%H-%M-%S')}.log"
Expand Down Expand Up @@ -67,7 +66,6 @@ def get_chat_template(chat_template):
template_path = os.path.join(script_dir, "chat_templates", f"{chat_template}.j2")

if not os.path.exists(template_path):
print
inference_logger.error(f"Template file not found: {chat_template}")
return None
try:
Expand Down Expand Up @@ -126,7 +124,7 @@ def validate_and_extract_tool_calls(assistant_content):
root = ET.fromstring(xml_root_element)

# extract JSON data
root_all = root.findall(".//tool_call")
root_all = root.findall(".//tool_calls")
inference_logger.info(f"root_all: {root_all}")
for element in root_all:
json_data = None
Expand Down

0 comments on commit 870788d

Please sign in to comment.