Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add debug dir for prompts #205

Merged
merged 4 commits into from
Mar 27, 2024
Merged

add debug dir for prompts #205

merged 4 commits into from
Mar 27, 2024

Conversation

rbren
Copy link
Collaborator

@rbren rbren commented Mar 26, 2024

This PR allows you to set PROMPT_DEBUG_DIR=./debug to get a record of every prompt and response. This helps agent creators debug their agents.

message_back = resp['choices'][0]['message']['content']
self.write_debug(messages, message_back)
return resp
self._completion = wrapper
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess by wrapping the ._completion function, we will break the documentation and argument hints

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, that's a bummer. What happens if we only wrap it when debug mode is on?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that that should make it work? since the wrapping is only happening at the runtime, and the argument hints only depends on static type?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 changed!

Copy link
Contributor

@xingyaoww xingyaoww left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


DEFAULT_MODEL = os.getenv("LLM_MODEL", "gpt-4-0125-preview")
DEFAULT_API_KEY = os.getenv("LLM_API_KEY")
PROMPT_DEBUG_DIR = os.getenv("PROMPT_DEBUG_DIR", "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need a centralized documents to keep track of all the Env Vars at some point :)

@xingyaoww
Copy link
Contributor

@rbren opps looks like we need to fix mypy's type issue, looks like allowing self._completion to have two types confuses mypy. I wonder if there's any way to disable the type check for mypy just for this?

image

@rbren
Copy link
Collaborator Author

rbren commented Mar 27, 2024

👍 found a way to make an exception

@rbren rbren merged commit 9bc1890 into main Mar 27, 2024
xcodebuild pushed a commit to xcodebuild/OpenDevin that referenced this pull request Mar 31, 2024
* add debug dir for prompts

* add indent to dumps

* only wrap completion in debug mode

* fix mypy
@rbren rbren deleted the rb/llm-debug branch April 22, 2024 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants