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

How to get formatted prompt? #3321

Closed
chengyjonathan opened this issue Apr 21, 2023 · 2 comments
Closed

How to get formatted prompt? #3321

chengyjonathan opened this issue Apr 21, 2023 · 2 comments

Comments

@chengyjonathan
Copy link

Hi there!

After setting up something like the following:

prompt = PromptTemplate.from_template("Some template")
chain = LLMChain(llm=some_llm, prompt=prompt)

Is there an easy way to get the formatted prompt?

Thank you

@chengyjonathan chengyjonathan changed the title How to pull out formatted prompt? How to get formatted prompt? Apr 21, 2023
@Daineng
Copy link

Daineng commented May 24, 2023

I have the same question. What is the answer?

@JminJ
Copy link

JminJ commented Aug 10, 2023

I found the answer in this script(https://linuxhint.com/use-langchain-llmchain-function-python/)

from langchain.prompts import PromptTemplate

from langchain.llms import OpenAI

import os

os.environ["OPENAI_API_KEY"] = "sk- Your-API-KEYllm = OpenAI(temperature=0.9)

prompt = PromptTemplate(

  input_variables=["Brand", "Product"],

  template="What would be the name of {Brand} that sells {Product}?",

)

from langchain.chains import LLMChain

chain = LLMChain(llm=llm, prompt=prompt)

print(chain.run({

  'Brand': "Art supplies",

  'Product': "colors"

}))

thanks Omar Farooq!

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

No branches or pull requests

3 participants