prompts-with-partial-func-example

command module
v0.0.0-...-e5f2120 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2024 License: MIT Imports: 4 Imported by: 0

README

Prompts with Partial Functions Example

This example demonstrates how to use the langchaingo library to create a prompt template with partial functions. The program showcases a simple yet powerful feature of dynamic prompt generation.

What This Example Does

  1. Prompt Template Creation: The example creates a PromptTemplate with a template string that includes placeholders for an adjective and a date.

  2. Partial Variables: It uses a partial variable for the date, which is a function that returns the current date formatted as "Month Day, Year".

  3. Dynamic Date Insertion: Every time the prompt is formatted, it automatically inserts the current date without needing to pass it as an input.

  4. User Input: The program allows for the adjective to be provided as an input when formatting the prompt.

  5. Prompt Formatting: It demonstrates how to format the prompt with the given input and the dynamically generated date.

  6. Output: The formatted prompt is printed to the console.

Key Features

  • Dynamic Content: Shows how to include dynamic content (current date) in prompts.
  • Partial Functions: Demonstrates the use of partial variables with functions.
  • Flexible Templating: Uses Go's template format for creating prompts.

Running the Example

When you run this example, it will output a prompt asking for a joke about the current date. The adjective "funny" is hardcoded in this example, but you could easily modify it to accept user input.

Example output:

Tell me a funny joke about the day March 14, 2024

This example is great for understanding how to create more dynamic and context-aware prompts in your language model applications using langchaingo.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL