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 prompt... syntax #717

Merged
merged 3 commits into from
Sep 19, 2024
Merged

add prompt... syntax #717

merged 3 commits into from
Sep 19, 2024

Conversation

pelikhan
Copy link
Member

@pelikhan pelikhan commented Sep 19, 2024

This pull request refactors the prompt handling in the core files and adds async dedent functionality. The prompt handling in the core files is updated to remove an asynchronous call and return statement. Additionally, the dedentAsync function is added to the indent.ts file, which allows for asynchronous dedenting of strings. This functionality is then used in the promptcontext.ts and promptdom.ts files to improve the handling of prompts.

  • 🛠️ A new constant DEDENT_INSPECT_MAX_DEPTH was added in the constants file.
  • 👀 In the "importprompt.ts" file, "prompt" was added to an exported object.
  • 🔄 The "indent.ts" file has a significant modification. A new function dedentAsync has been implemented. This function asynchronously indents multi-line string templates and handles the resolution of arguments including arrays and objects.
  • 🎭 In "promptcontext.ts", a new functionality is implemented in the form of a function named prompt. It performs asynchronous operations, handles any exceptions, and ties it together with the runPrompt function.
  • 💼 Import of dedentAsync is added in "promptdom.ts" and "promptcontext.ts" file, and the function is used to reduce complexity of stringTemplate function in "promptdom.ts".
  • 📃 Updates are made in the "prompt_template.d.ts" and "prompt_type.d.ts" files which are user-facing public API changes. A new interface RunPromptResultPromiseWithOptions was defined, and a new function prompt is included in the ChatGenerationContext interface.
  • 🎶 Lastly, in the "nested-poets.genai.mts" file, runPrompt function is replaced with the newly created prompt function along with the usage of string templates.

generated by pr-describe

Copy link

The pull request introduces the following changes:

  1. A new constant DEDENT_INSPECT_MAX_DEPTH is added to constants.ts.
  2. An import for prompt is added to importprompt.ts.
  3. A new async function dedentAsync is added to indent.ts which seems to handle the dedenting of async templates. The function also uses the new DEDENT_INSPECT_MAX_DEPTH constant.
  4. The createPromptContext in promptcontext.ts is updated to include a new prompt function that appears to resolve a prompt with dedentAsync.
  5. The resolvePromptNode function in promptdom.ts is refactored to use the new dedentAsync function.
  6. Two new interface RunPromptResultPromiseWithOptions and new method prompt are added in prompt_template.d.ts.
  7. The prompt function is also declared in prompt_type.d.ts.

Overall, it seems like the changes are centered around improving the handling of prompts, especially when it comes to asynchronous operations. The changes appear to be well-structured and nicely integrated with the existing codebase.

However, the changes lack documentation and comments. It might be beneficial to provide some comments explaining the reasoning behind these changes and how the new features are supposed to work.

Apart from that, LGTM 🚀

generated by pr-review

@pelikhan pelikhan changed the title Refactor prompt handling and add async dedent functionality add prompt... syntax Sep 19, 2024
@pelikhan pelikhan merged commit 052a523 into main Sep 19, 2024
8 of 9 checks passed
@pelikhan pelikhan deleted the promptliteral branch September 19, 2024 15:23
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.

1 participant