mirror of
https://github.com/aljazceru/gpt-engineer.git
synced 2025-12-17 12:45:26 +01:00
Add --verbose option for logging request/response
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
import openai
|
import openai
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class AI:
|
class AI:
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
@@ -36,6 +40,7 @@ class AI:
|
|||||||
if prompt:
|
if prompt:
|
||||||
messages = messages + [{"role": "user", "content": prompt}]
|
messages = messages + [{"role": "user", "content": prompt}]
|
||||||
|
|
||||||
|
logger.debug(f"Creating a new chat completion: {messages}")
|
||||||
response = openai.ChatCompletion.create(
|
response = openai.ChatCompletion.create(
|
||||||
messages=messages, stream=True, **self.kwargs
|
messages=messages, stream=True, **self.kwargs
|
||||||
)
|
)
|
||||||
@@ -46,4 +51,6 @@ class AI:
|
|||||||
msg = delta.get("content", "")
|
msg = delta.get("content", "")
|
||||||
print(msg, end="")
|
print(msg, end="")
|
||||||
chat.append(msg)
|
chat.append(msg)
|
||||||
return messages + [{"role": "assistant", "content": "".join(chat)}]
|
messages = messages + [{"role": "assistant", "content": "".join(chat)}]
|
||||||
|
logger.debug(f"Chat completion finished: {messages}")
|
||||||
|
return messages
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import shutil
|
import shutil
|
||||||
@@ -26,7 +27,10 @@ def chat(
|
|||||||
model: str = "gpt-4",
|
model: str = "gpt-4",
|
||||||
temperature: float = 0.1,
|
temperature: float = 0.1,
|
||||||
steps_config: str = "default",
|
steps_config: str = "default",
|
||||||
|
verbose: bool = typer.Option(False, "--verbose", "-v"),
|
||||||
):
|
):
|
||||||
|
logging.basicConfig(level=logging.DEBUG if verbose else logging.INFO)
|
||||||
|
|
||||||
app_dir = pathlib.Path(os.path.curdir)
|
app_dir = pathlib.Path(os.path.curdir)
|
||||||
input_path = pathlib.Path(app_dir / "projects" / project_path)
|
input_path = pathlib.Path(app_dir / "projects" / project_path)
|
||||||
memory_path = input_path / (run_prefix + "memory")
|
memory_path = input_path / (run_prefix + "memory")
|
||||||
|
|||||||
Reference in New Issue
Block a user