Advertisement

LangChain: Prompt的使用

阅读量:

1. Prompt基本使用

复制代码
    from langchain_core.prompts import PromptTemplate
    from langchain_core.prompts import ChatPromptTemplate
    
    
      
      
    

当前存在两种类型的prompt,分别对应不同的表现形式,即PromptTemplate与ChatPromptTemplate。从一定角度来看,前者属于一种普遍适用的模板结构,而后者则是针对对话场景所设计的特定表达方式。

复制代码
    from langchain_core.prompts import PromptTemplate
    
    prompt_template = PromptTemplate.from_template(
    "Tell me a {adjective} joke about {content}."
    )
    prompt_template.format(adjective="funny", content="chickens")
    # 'Tell me a funny joke about chickens.'
    
    
      
      
      

全部评论 (0)

还没有任何评论哟~