-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
32 lines (22 loc) · 811 Bytes
/
main.py
File metadata and controls
32 lines (22 loc) · 811 Bytes
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
28
29
30
31
32
import os
import requests
from dotenv import load_dotenv
from langchain_google_genai import ChatGoogleGenerativeAI
load_dotenv()
SERPAPI_KEY = "5c523f264902e5b61c07076fb54c538bed04dfa18c9cdbf4ebdb642bfa694a29"
GEMINI_KEY = "AIzaSyDWzqUwAyAYPVt7Bv-HY6c3i77_Zd02Z2Y"
llm = ChatGoogleGenerativeAI(
model = "gemini-2.5-flash",
google_api_key = GEMINI_KEY
)
# content = llm.invoke(input("Enter query : ")).content
# print(content)
from langchain_google_genai import GoogleGenerativeAIEmbeddings
import getpass
import os
if not os.environ.get("GOOGLE_API_KEY"):
os.environ["GOOGLE_API_KEY"] = getpass.getpass("Enter API key for Google Gemini: ")
embeddings = GoogleGenerativeAIEmbeddings(model="models/gemini-embedding-001")
vector = embeddings.embed_query("hello, world!")
v=vector[:5]
print(v)