Migrieren Sie von LLMchain zum RohroperatorPython

Python-Programme
Anonymous
 Migrieren Sie von LLMchain zum Rohroperator

Post by Anonymous »

Ich verfolgte ein altes Tutorial über die Verkettung in Langchain. Damit habe ich einige eigene Demo-Ketten geschrieben, wie: < /p>
prompt_candidates = ChatPromptTemplate.from_template(
"""A research has shown that the following SUBJECTS are somehow related with the CAREER '{career}':

{research_list}

From the SUBJECTS list, get me a list of ACADEMIC THEMES. The ACADEMIC THEMES list must accomplish the following requirements:

[Long list of requirements, shortened for both readability and propietary contents]
"""
)

prompt_finalists = ChatPromptTemplate.from_template(
"""I have a list of ACADEMIC THEMES, all of them for the CAREER '{career}':

{academic_themes}

Another Curricular Design Expert has determined however, that these ACADEMIC THEMES need the following CORRECTIONS:

[Another long list of requirements, shortened for both readability and propietary contents]

Rewrite the ACADEMIC THEMES, so they become compliant with the CORRECTIONS raised.
"""
)

# Chains definition
candidates_chain = LLMChain(llm=llm, prompt=prompt_candidates, output_key="academic_themes")
finalists_chain = LLMChain(llm=llm, prompt=prompt_finalists, output_key="finalists")

# Chaining
final_chain = SequentialChain(
chains=[candidates_chain, finalists_chain],
input_variables=["career", "research_list"],
output_variables=["finalists"],
verbose=False
)
< /code>
Ich habe jedoch die folgende Warnung erhalten: < /p>
LangChainDeprecationWarning: The class `LLMChain` was deprecated in LangChain 0.1.17 and will be removed in 1.0. Use RunnableSequence, e.g., `prompt | llm` instead.
candidates_chain = LLMChain(llm=llm, prompt=prompt_candidates, output_key="academic_themes")
< /code>
In der Tat habe ich die Dokumente gelesen, die Sie aufforderten, das Rohr "|" zu verwenden. Operator; Die dort vorgesehenen Beispiele sind jedoch sehr einfach und beinhalten normalerweise eine Eingabeaufforderung und eine LLM, die sehr einfach sind (und sind sogar in derselben Warnmeldung bereitgestellt). Ich konnte jedoch nicht herausfinden, wie ich den Rohroperator in meiner eigenen Kette anpassen konnte. Py PrettyPrint-Override ">from langchain_core.output_parsers import StrOutputParser

chain_a = prompt_candidates | llm | StrOutputParser()
chain_b = prompt_finalists | llm | StrOutputParser()
composed_chain = chain_a | chain_b
output_chain=composed_chain.invoke(
{
"career": "Artificial Intelligence",
"research_list": "\n".join(research_col)
}
)
< /code>
Aber das bringt mich dazu: < /p>
TypeError: Expected mapping type as input to ChatPromptTemplate. Received .
< /code>
Ich habe mehrere Sachen ausprobiert, aber nichts Funktionales. Was mache ich falsch?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post