Sequential chains

LangChain के साथ LLM एप्लिकेशन विकसित करना

Jonathan Bennion

AI Engineer & LangChain Contributor

 

एक AI ट्रैवल गाइड.

LangChain के साथ LLM एप्लिकेशन विकसित करना

 

एक व्यक्ति पेरिस में करने लायक गतिविधियों के लिए AI ट्रैवल गाइड से पूछता है.

LangChain के साथ LLM एप्लिकेशन विकसित करना

 

AI व्यक्ति को पेरिस में कई गतिविधियों के सुझाव देता है.

LangChain के साथ LLM एप्लिकेशन विकसित करना

 

व्यक्ति AI गाइड को बताता है कि वह लौवर और आर्क दे ट्रायोंफ देखना चाहता है.

LangChain के साथ LLM एप्लिकेशन विकसित करना

 

AI ट्रैवल गाइड चुनी हुई गतिविधियों के लिए एक यात्रा-कार्यक्रम बनाता है.

LangChain के साथ LLM एप्लिकेशन विकसित करना

 

यह ट्रैवल इटिनरेरी वर्कफ़्लो एक sequential problem का उदाहरण है.

LangChain के साथ LLM एप्लिकेशन विकसित करना

Sequential chains

  • आउटपुट → इनपुट
destination_prompt = PromptTemplate(
    input_variables=["destination"],
    template="I am planning a trip to {destination}. Can you suggest some activities to do there?"
)

activities_prompt = PromptTemplate( input_variables=["activities"], template="I only have one day, so can you create an itinerary from your top three activities: {activities}." )
llm = ChatOpenAI(model="gpt-4o-mini", api_key=openai_api_key)
seq_chain = ({"activities": destination_prompt | llm | StrOutputParser()}
| activities_prompt | llm | StrOutputParser())
LangChain के साथ LLM एप्लिकेशन विकसित करना
print(seq_chain.invoke({"destination": "Rome"}))
- Morning:
1. Start your day early with a visit to the Colosseum. Take a guided tour to learn about its history and significance.
2. After exploring the Colosseum, head to the Roman Forum and Palatine Hill to see more of ancient Rome's ruins.

- Lunch:
3. Enjoy a delicious Italian lunch at a local restaurant near the historic center.

- Afternoon:
4. Visit the Vatican City and explore St. Peter's Basilica, the Vatican Museums, and the Sistine Chapel.
5. Take some time to wander through the charming streets of Rome, stopping at landmarks like the Pantheon, Trevi
Fountain, and Piazza Navona.

- Evening:
6. Relax in one of Rome's beautiful parks, such as Villa Borghese or the Orange Garden, for a peaceful escape from the
bustling city.
7. End your day with a leisurely dinner at a local restaurant, indulging in more Italian cuisine and maybe some gelato.
LangChain के साथ LLM एप्लिकेशन विकसित करना

अभ्यास करते हैं!

LangChain के साथ LLM एप्लिकेशन विकसित करना

Preparing Video For Download...