Files
test-small-llms/libs/runnables.py
2024-08-04 20:50:11 +02:00

17 lines
509 B
Python

from langchain_ollama.chat_models import ChatOllama
from langchain_core.messages import SystemMessage, HumanMessage
from libs.test_class import Test
def basic(model: str, seed: int, test: Test, base_url: str) -> str:
if test.system_msg == None: prompt = [ test.human_msg ]
else: prompt = [ test.system_msg, test.human_msg ]
llm = ChatOllama(
model=model,
seed=seed,
base_url=base_url
)
ai_msg = llm.invoke(prompt)
return ai_msg.content