prompts-with-partial-func-example

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

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

Go to latest
Published: Jun 28, 2025 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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