-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
21 lines (15 loc) · 667 Bytes
/
Copy pathtest.py
File metadata and controls
21 lines (15 loc) · 667 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from langchain_google_genai import GoogleGenerativeAI
from langchain.schema.output_parser import StrOutputParser
import os
from dotenv import load_dotenv
from AI_model.prompt_templates import generate_story_prompt
load_dotenv()
def generate_story(question: str):
"""Generates a story using a language model and returns the response."""
llm = GoogleGenerativeAI(model="gemini-2.5-pro",
api_key=os.getenv("GOOGLE_API_KEY"))
prompt = generate_story_prompt()
chain = prompt | llm | StrOutputParser()
response_llm = chain.invoke({"question": question})
return response_llm
print(generate_story("detective duck"))