Skip to content

Commit 2fdd634

Browse files
committed
add tool call for ollama
1 parent 42cb84c commit 2fdd634

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

scripts/ollama_operator.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,49 @@ class ReceiptInfo(BaseModel):
289289
)
290290

291291

292+
@app.command()
293+
def tool(
294+
query: str = typer.Option(
295+
"Please investigate troubleshooting cases for KABUTO.",
296+
"--query",
297+
"-q",
298+
help="Query for chat",
299+
),
300+
model: str = typer.Option(
301+
"phi3:3.8b-mini-4k-instruct-q2_K",
302+
"--model",
303+
"-m",
304+
help="Model to use for Ollama",
305+
),
306+
verbose: bool = typer.Option(
307+
False,
308+
"--verbose",
309+
"-v",
310+
help="Enable verbose output",
311+
),
312+
):
313+
set_verbose_logging(verbose)
314+
315+
from template_langgraph.tools.common import get_default_tools
316+
317+
chat_model = OllamaWrapper(
318+
settings=Settings(
319+
ollama_model_chat=model,
320+
)
321+
).chat_model
322+
response = chat_model.bind_tools(tools=get_default_tools()).invoke(
323+
input=[
324+
query,
325+
],
326+
)
327+
logger.info(
328+
response.model_dump_json(
329+
indent=2,
330+
exclude_none=True,
331+
)
332+
)
333+
334+
292335
if __name__ == "__main__":
293336
load_dotenv(
294337
override=True,

0 commit comments

Comments
 (0)