Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ import os
|
|
4 |
import json
|
5 |
import google.generativeai as genai
|
6 |
from bs4 import BeautifulSoup
|
|
|
7 |
#from groq import Groq
|
8 |
# Load environment variables
|
9 |
genai.configure(api_key=os.environ["geminiapikey"])
|
@@ -21,6 +22,49 @@ custom_css = """
|
|
21 |
}
|
22 |
"""
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
#api_key = os.getenv('groq')
|
25 |
google_api_key = os.getenv('google_search')
|
26 |
API_URL = "https://blavken-flowiseblav.hf.space/api/v1/prediction/fbc118dc-ec00-4b59-acff-600648958be3"
|
@@ -97,7 +141,7 @@ with gr.Blocks(css=custom_css) as demo:
|
|
97 |
button = gr.Button("Senden")
|
98 |
|
99 |
# Connect the button to the function
|
100 |
-
button.click(fn=
|
101 |
|
102 |
# Launch the Gradio application
|
103 |
demo.launch()
|
|
|
4 |
import json
|
5 |
import google.generativeai as genai
|
6 |
from bs4 import BeautifulSoup
|
7 |
+
from google.ai.generativelanguage_v1beta.types import content
|
8 |
#from groq import Groq
|
9 |
# Load environment variables
|
10 |
genai.configure(api_key=os.environ["geminiapikey"])
|
|
|
22 |
}
|
23 |
"""
|
24 |
|
25 |
+
generation_config = {
|
26 |
+
"temperature": 0.3,
|
27 |
+
"top_p": 0.95,
|
28 |
+
"top_k": 64,
|
29 |
+
"max_output_tokens": 8192,
|
30 |
+
"response_mime_type": "text/plain",
|
31 |
+
}
|
32 |
+
|
33 |
+
def ground_search(prompt):
|
34 |
+
model = genai.GenerativeModel(
|
35 |
+
model_name="gemini-2.0-pro-exp-02-05",
|
36 |
+
generation_config=generation_config,
|
37 |
+
tools = [
|
38 |
+
genai.protos.Tool(
|
39 |
+
google_search = genai.protos.Tool.GoogleSearch(),
|
40 |
+
),
|
41 |
+
],
|
42 |
+
)
|
43 |
+
|
44 |
+
chat_session = model.start_chat(
|
45 |
+
history=[
|
46 |
+
{
|
47 |
+
"role": "user",
|
48 |
+
"parts": [
|
49 |
+
"",
|
50 |
+
],
|
51 |
+
},
|
52 |
+
{
|
53 |
+
"role": "model",
|
54 |
+
"parts": [
|
55 |
+
"",
|
56 |
+
],
|
57 |
+
},
|
58 |
+
]
|
59 |
+
)
|
60 |
+
|
61 |
+
response = chat_session.send_message(f"{prompt}")
|
62 |
+
|
63 |
+
#print(response.text)
|
64 |
+
return response.text
|
65 |
+
|
66 |
+
|
67 |
+
|
68 |
#api_key = os.getenv('groq')
|
69 |
google_api_key = os.getenv('google_search')
|
70 |
API_URL = "https://blavken-flowiseblav.hf.space/api/v1/prediction/fbc118dc-ec00-4b59-acff-600648958be3"
|
|
|
141 |
button = gr.Button("Senden")
|
142 |
|
143 |
# Connect the button to the function
|
144 |
+
button.click(fn=ground_search, inputs=ort_input, outputs=details_output)
|
145 |
|
146 |
# Launch the Gradio application
|
147 |
demo.launch()
|