henryhyunwookim
commited on
Update app.py
Browse filesupdate to handle google api key
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import serpapi
|
2 |
import gradio as gr
|
3 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
@@ -5,7 +6,7 @@ from langchain_google_genai import ChatGoogleGenerativeAI
|
|
5 |
from utils.utils import summarize_search_result, get_prompt
|
6 |
|
7 |
|
8 |
-
def main(search_query, search_location, serp_api_key):
|
9 |
search_response = serpapi.search(
|
10 |
q=search_query,
|
11 |
location=search_location,
|
@@ -16,6 +17,7 @@ def main(search_query, search_location, serp_api_key):
|
|
16 |
|
17 |
prompt = get_prompt(search_query, search_summary)
|
18 |
|
|
|
19 |
chat_model = ChatGoogleGenerativeAI(
|
20 |
model="gemini-pro",
|
21 |
convert_system_message_to_human=True,
|
@@ -34,7 +36,8 @@ if __name__ == "__main__":
|
|
34 |
inputs=[
|
35 |
gr.Textbox(label="Search Query (検索クエリ)"),
|
36 |
gr.Textbox(label="Search Location (検索を行う国を英語で入力してください)"),
|
37 |
-
gr.Textbox(label="SERP API Key (https://serpapi.com/manage-api-key)")
|
|
|
38 |
],
|
39 |
outputs=[gr.Textbox(label="Search Result (検索結果)")],
|
40 |
title="Google Search enhanced by LLM"
|
|
|
1 |
+
import os
|
2 |
import serpapi
|
3 |
import gradio as gr
|
4 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
|
|
6 |
from utils.utils import summarize_search_result, get_prompt
|
7 |
|
8 |
|
9 |
+
def main(search_query, search_location, serp_api_key, google_api_key):
|
10 |
search_response = serpapi.search(
|
11 |
q=search_query,
|
12 |
location=search_location,
|
|
|
17 |
|
18 |
prompt = get_prompt(search_query, search_summary)
|
19 |
|
20 |
+
os.environ["GOOGLE_API_KEY"] = google_api_key
|
21 |
chat_model = ChatGoogleGenerativeAI(
|
22 |
model="gemini-pro",
|
23 |
convert_system_message_to_human=True,
|
|
|
36 |
inputs=[
|
37 |
gr.Textbox(label="Search Query (検索クエリ)"),
|
38 |
gr.Textbox(label="Search Location (検索を行う国を英語で入力してください)"),
|
39 |
+
gr.Textbox(label="SERP API Key (https://serpapi.com/manage-api-key)"),
|
40 |
+
gr.Textbox(label="Google API Key (https://console.cloud.google.com/apis/credentials)")
|
41 |
],
|
42 |
outputs=[gr.Textbox(label="Search Result (検索結果)")],
|
43 |
title="Google Search enhanced by LLM"
|