import os
from dotenv import load_dotenv
load_dotenv()
import google.generativeai as genai
from langchain_google_genai import GoogleGenerativeAI
# Ensure your GOOGLE_API_KEY is set in the .env file
api_key = os.getenv("GEMINI_API_KEY")
# Use GoogleGenerativeAI instead of GooglePalm
llm = GoogleGenerativeAI(model="models/gemini-1.0-pro",
google_api_key=api_key,
temperature=0.1)
from langchain_experimental.sql import SQLDatabaseChain
db_chain = SQLDatabaseChain.from_llm(
llm=llm,
db=db,
verbose=True,
use_query_checker=True)
result = db_chain.run("What is the min date?")
OUTPUT:
Entering new SQLDatabaseChain chain…
What is the minimum date?
SQLQuery:”’sql
SELECT MIN(date) AS min_date FROMgcs_data
;
”’
Due to this ”’ sql I’m getting the error from Google Big Query as:
Syntax error: Unexpected identifier “` at [1:1]
How to solve this problem…?
I tried to find some solutions using blackbox.ai and chatgpt as well, but couldn’t get the issue resolved. Can anyone help me out to remove this error.