Spaces:
Sleeping
Sleeping
File size: 568 Bytes
5e653d4 2f91ca9 3d952a8 5e653d4 331ad7a 5e653d4 331ad7a 5e653d4 d0bd4b6 5e653d4 d0bd4b6 331ad7a 5e653d4 430bae8 5e653d4 2f91ca9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | import os
from langchain_google_genai import ChatGoogleGenerativeAI
gemma_model = ChatGoogleGenerativeAI(
model="gemma-3-12b-it",
temperature=0,
max_tokens=2048,
timeout=None,
max_retries=2,
)
def generate_response(prompt: str, context: str="", history: list = []):
if context == "":
message = history + [{"role" : "user", "content" : prompt}]
else:
message = history + [{"role" : "user", "content" : f"Context : {context}\nQuery : {prompt}"}]
response = gemma_model.invoke(message)
return response.content
|