-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
22 lines (19 loc) · 870 Bytes
/
bot.py
File metadata and controls
22 lines (19 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import google.generativeai as genai
import os
from langchain_community.document_loaders import WebBaseLoader
url = 'https://arxiv.org/abs/2402.05935'
loader = WebBaseLoader(url)
data = loader.load()
print(data[0].page_content)
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
model = genai.GenerativeModel('gemini-pro')
while True:
question = input("Enter your query: ")
prompt = f"""Answer the question as precise as possible using the provided context. This context is scraped from a website, so if user mentions website, he means this given context.
Only return the helpful answer below and nothing else.\n\n
Context: \n {data[0].page_content}?\n
Question: \n {question} \n
Answer:
"""
response = model.generate_content(prompt)
print(response.text)