aboutsummaryrefslogtreecommitdiff
path: root/llm.py
diff options
context:
space:
mode:
Diffstat (limited to 'llm.py')
-rwxr-xr-xllm.py36
1 files changed, 9 insertions, 27 deletions
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()