-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprompt_template_multiple_variable.py
27 lines (20 loc) · 1.4 KB
/
prompt_template_multiple_variable.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# LangChain + Google Gemini AI Integration Example
# Author: Hassan Mehmood
# Demonstrates This is the example of prompt template with multiple variables.
from gemini import GoogleGeminiModel
def main():
# Define the text to process (could be any input for translation or extraction)
word_to_translate = """LangChain provides a modular framework for developing applications with large language models. It allows developers to chain together tools, handle memory, and use different models to create more powerful solutions. LangChain has been used for building chatbots, document analysis tools, and other AI-powered applications."""
# Define the prompt template for extracting key facts
template = "Extract {action} from the following text: {text}. Provide a list of the most important points."
# Initialize the GoogleGeminiModel instance
gemini_model = GoogleGeminiModel()
# Execute the chain using the defined prompt and input text
print(f"🌍 Executing the chain for the input: {word_to_translate}")
response = gemini_model.execute_chain(prompt_template=template, input_text={"action": "3 facts", "text": word_to_translate}, input_variables=["action", "text"])
# Display the result
print("============================================")
print(f"🌟 Response Result: {response}")
print("============================================")
if __name__ == "__main__":
main()