Merge pull request #35 from jepler/misc-improvements
switch openai default to gpt-4-turbo
This commit is contained in:
commit
79997215ad
4 changed files with 37 additions and 8 deletions
|
|
@ -66,8 +66,8 @@ class EncodingMeta:
|
|||
class ChatGPT:
|
||||
@dataclass
|
||||
class Parameters:
|
||||
model: str = "gpt-3.5-turbo"
|
||||
"""The model to use. The most common alternative value is 'gpt-4'."""
|
||||
model: str = "gpt-4-turbo"
|
||||
"""The model to use. The most common alternative value is 'gpt-3.5-turbo'."""
|
||||
|
||||
max_request_tokens: int = 1024
|
||||
"""The approximate greatest number of tokens to send in a request. When the session is long, the system prompt and 1 or more of the most recent interaction steps are sent."""
|
||||
|
|
|
|||
|
|
@ -100,8 +100,9 @@ def verbose_ask(api: Backend, session: Session, q: str, print_prompt: bool) -> s
|
|||
|
||||
@command_uses_new_session
|
||||
@click.option("--print-prompt/--no-print-prompt", default=True)
|
||||
@click.argument("prompt", nargs=-1, required=True)
|
||||
def main(obj: Obj, prompt: str, print_prompt: bool) -> None:
|
||||
@click.option("--stdin/--no-stdin", "use_stdin", default=False)
|
||||
@click.argument("prompt", nargs=-1)
|
||||
def main(obj: Obj, prompt: list[str], use_stdin: bool, print_prompt: bool) -> None:
|
||||
"""Ask a question (command-line argument is passed as prompt)"""
|
||||
session = obj.session
|
||||
assert session is not None
|
||||
|
|
@ -112,9 +113,16 @@ def main(obj: Obj, prompt: str, print_prompt: bool) -> None:
|
|||
api = obj.api
|
||||
assert api is not None
|
||||
|
||||
if use_stdin:
|
||||
if prompt:
|
||||
raise click.UsageError("Can't use 'prompt' together with --stdin")
|
||||
|
||||
joined_prompt = sys.stdin.read()
|
||||
else:
|
||||
joined_prompt = " ".join(prompt)
|
||||
# symlink_session_filename(session_filename)
|
||||
|
||||
response = verbose_ask(api, session, " ".join(prompt), print_prompt=print_prompt)
|
||||
response = verbose_ask(api, session, joined_prompt, print_prompt=print_prompt)
|
||||
|
||||
print(f"Saving session to {session_filename}", file=sys.stderr)
|
||||
if response is not None:
|
||||
|
|
|
|||
|
|
@ -292,7 +292,9 @@ def main(obj: Obj, replace_system_prompt: bool) -> None:
|
|||
assert session_filename is not None
|
||||
|
||||
if replace_system_prompt:
|
||||
session[0].content = obj.system_message or api.system_message
|
||||
session[0].content = (
|
||||
api.system_message if obj.system_message is None else obj.system_message
|
||||
)
|
||||
|
||||
tui = Tui(api, session)
|
||||
tui.run()
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
import asyncio
|
||||
import datetime
|
||||
import io
|
||||
import importlib
|
||||
import os
|
||||
import pathlib
|
||||
|
|
@ -177,12 +178,23 @@ def colonstr(arg: str) -> tuple[str, str]:
|
|||
|
||||
|
||||
def set_system_message(ctx: click.Context, param: click.Parameter, value: str) -> None:
|
||||
if value and value.startswith("@"):
|
||||
if value is None:
|
||||
return
|
||||
if value.startswith("@"):
|
||||
with open(value[1:], "r", encoding="utf-8") as f:
|
||||
value = f.read().rstrip()
|
||||
value = f.read().strip()
|
||||
ctx.obj.system_message = value
|
||||
|
||||
|
||||
def set_system_message_from_file(
|
||||
ctx: click.Context, param: click.Parameter, value: io.TextIOWrapper
|
||||
) -> None:
|
||||
if value is None:
|
||||
return
|
||||
content = value.read().strip()
|
||||
ctx.obj.system_message = content
|
||||
|
||||
|
||||
def set_backend(ctx: click.Context, param: click.Parameter, value: str) -> None:
|
||||
if value == "list":
|
||||
formatter = ctx.make_formatter()
|
||||
|
|
@ -369,6 +381,13 @@ main = MyCLI(
|
|||
help="Show the version and exit",
|
||||
callback=version_callback,
|
||||
),
|
||||
click.Option(
|
||||
("--system-message-file", "-@"),
|
||||
type=click.File("r"),
|
||||
default=None,
|
||||
callback=set_system_message_from_file,
|
||||
expose_value=False,
|
||||
),
|
||||
click.Option(
|
||||
("--system-message", "-S"),
|
||||
type=str,
|
||||
|
|
|
|||
Loading…
Reference in a new issue