ai_agent
Python ai agent to summarize text with AI from user inputs
https://github.com/piotrr79/ai_agent
from pathlib import Path
from ctransformers import AutoModelForCausalLM
class Validator:
""" Validator class """
def __init__(self):
pass
def call_internal_model(self, prompt: str, tokens: int, temp: float) -> list:
""" Call Llama
Returns:
List
"""
response = []
app_dir = Path(__file__).resolve().parent.parent.parent.parent
llm = AutoModelForCausalLM.from_pretrained(
model_path_or_repo_id = str(app_dir) + '/ai_agent/summarizer/libs/',
model_type = 'llama',
model_file = 'llama-2-7b-chat.ggmlv3.q4_K_S.bin',
local_files_only = True)
output = llm(prompt, max_new_tokens=tokens, temperature=temp)
#response.append(output.replace("?\n ", "").replace("\n\n", ""))
response.append(output)
return response
POC of application for summarizing text with AI. App utilize locally deployed SLM / LLM (currently Llama) and external OpenAI. Can be used for testing varoius SLM / LLM models run on locally on CPU.