prompts-with-partial-example

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

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

Go to latest
Published: Sep 13, 2024 License: MIT Imports: 3 Imported by: 0

README

Prompts with Partial Example

Hello there! 👋 Welcome to this fun little Go example that showcases how to use prompts with partial variables using the langchaingo library. Let's dive in and see what this code does!

What's This All About?

This example demonstrates how to create a prompt template with both regular input variables and partial variables. It's a great way to see how flexible and powerful prompt templates can be!

The Magic Explained

Here's what's happening in our code:

  1. We create a PromptTemplate with the following properties:

    • A template string: "{{.foo}}{{.bar}}"
    • An input variable: "bar"
    • A partial variable: "foo" with the value "foo"
    • The template format is set to Go's template format
  2. We then format the prompt by providing a value for the "bar" variable.

  3. Finally, we print the result!

What to Expect

When you run this code, you'll see the output:

foobaz

Isn't that neat? The "foo" comes from our partial variable, and "baz" is the value we provided for the "bar" input variable.

Why This Matters

This example shows how you can create flexible templates with some pre-defined parts (partial variables) and other parts that can be filled in later (input variables). It's super useful for creating dynamic prompts in various applications!

Give It a Try!

Feel free to play around with the code. Try changing the template, adding more variables, or experimenting with different values. The world of prompt templates is your oyster! 🦪

Happy coding, and may your prompts always be perfectly formatted! 🚀✨

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