From 24309a822aa56e624f280a095b9d92d32f8c18bb Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Sun, 11 Oct 2026 23:26:03 +0300 Subject: feat: webgrep --- llm.py | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) (limited to 'llm.py') diff --git a/llm.py b/llm.py index bea4536..9b6208d 100755 --- a/llm.py +++ b/llm.py @@ -2,7 +2,7 @@ import os from pathlib import Path from openai import OpenAI -from typing import Optional, List, Dict, TypeVar, TypeAlias +from typing import Optional, List, Dict, TypeVar, TypeAlias, Callable import argparse import re import subprocess @@ -29,6 +29,7 @@ class AgentConfig: actions: List["Action"] trustlevels: Dict[str, int] trustlevel: int + search_padding: int = 200 client = OpenAI( @@ -46,28 +47,6 @@ def direct_query(query: str): return res.output_text -# def reason_query(input): -# # TODO some models may natively support reasoning - -# reasoning = direct_query(input + ({"role": "system", -# "content": "Reason about the user's query step by step.\n\nAn answer will be generated based on your analysis."},)) - -# summary = direct_query(input + ({"role": "assistant", "content": reasoning}, -# {"role": "system", -# "content": "Formulate your previous reasoning as a concise answer to the user."})) - -# return summary - -# # kinda funky -# # def flexible_query(input): - -# # reasoning_required = direct_query(input[-1:] + ({"role": "system", "content": "Does answering the user's question require reasoning? (y|N)"},)) -# # if reasoning_required == 'y': -# # return reason_query(input) -# # else: -# # return direct_query(input) - - def chat(content, state=(), query_method=direct_query, role="user"): state = state + ({"role": role, "content": content},) @@ -144,16 +123,17 @@ def main(): config = AgentConfig( workdir=args.workdir, - actions=[ls, read, write, tldr, shell, mypy], + actions=[ls, read, write, tldr, shell, mypy, webgrep], trustlevels={ "ls": 0, "read": 0, "tldr": 0, "mypy": 0, - "write": 1, - "shell": 2, + "webgrep": 1, + "write": 2, + "shell": 3, }, - trustlevel=1, + trustlevel=2, ) state = ( @@ -172,6 +152,8 @@ Once you are finished with your task, give a response with none of the above JSO }, ) + print(state) + while True: query = input("> ").strip() -- cgit v1.3.1