Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Databricks Certified Generative AI Engineer Associate Exam - Topic 6 Question 35 Discussion

Posted by Portia on Sep 27, 2026 at 06:23 PM

A Generative AI Engineer is testing a simple prompt template in LangChain using the code below, but is getting an error:

Python

from langchain.chains import LLMChain

from langchain_community.llms import OpenAI

from langchain_core.prompts import PromptTemplate

prompt_template = "Tell me a {adjective} joke"

prompt = PromptTemplate(input_variables=["adjective"], template=prompt_template)

# ... (Error-prone section)

Assuming the API key was properly defined, what change does the Generative AI Engineer need to make to fix their chain?

Suggested Answer: C

The error in the original snippet usually stems from the improper instantiation of the LLMChain or the incorrect call to the .generate() method. In LangChain, an LLMChain requires two primary components: an LLM (the engine) and a Prompt (the template). Option C provides the correct syntax: first, the PromptTemplate is defined with the correct input_variables. Second, the OpenAI model is instantiated. Third, the LLMChain binds the model and the prompt together. Finally, the .generate() method expects a list of dictionaries, where each dictionary represents a set of inputs for the prompt variables. Options A, B, and D in the original image contain syntax errors such as passing the variable directly into the chain initialization or missing the dictionary list format required by the standard LangChain API for batch-like generation.


Get Premium Databricks Certified Generative AI Engineer Associate Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
9 comments · newest first
HO
Hollis 3 days ago
This seems too simple, something feels off here.
LO
Louis 8 days ago
I thought LangChain was supposed to be easy to use?
SE
Selma 14 days ago
Wait, are they sure the API key is set? That could be the issue too.
AD
Adolph 19 days ago
Definitely option C, that’s the right structure!
MA
Marshall 24 days ago
Looks like they just need to set up the LLMChain correctly.
BE
Becky 29 days ago
I think option C looks right, but I’m a bit confused about how to ensure the API key is set up correctly. Did we cover that in our sessions?
CY
Cyril 1 month ago
I recall that the input variables have to match exactly with what the prompt expects. If there's a mismatch, it could lead to an error.
BR
Brandon 1 month ago
I'm not entirely sure, but I feel like we practiced a similar question where the prompt needed to be correctly linked to the LLM. Maybe that's the problem here?
GE
Georgene 1 month ago
I think the issue might be with how the LLMChain is set up. I remember something about needing to properly initialize the LLM before using it.
0/2000 characters

Save Cancel