Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,26 +2,17 @@ import os
|
|
| 2 |
import gradio as gr
|
| 3 |
from google import genai
|
| 4 |
|
| 5 |
-
# Read API key
|
| 6 |
-
GEMINI_API_KEY = os.getenv("GEMINI_API_KEY")
|
| 7 |
-
|
| 8 |
def qa_ai_bot(message, history):
|
| 9 |
-
|
| 10 |
-
return "❌ GEMINI_API_KEY not set in Space variables."
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
prompt = f"""
|
| 15 |
-
You are an expert QA Automation Engineer.
|
| 16 |
-
Answer with examples when required.
|
| 17 |
|
| 18 |
-
|
| 19 |
-
{message}
|
| 20 |
-
"""
|
| 21 |
|
| 22 |
response = client.models.generate_content(
|
| 23 |
model="gemini-1.5-flash",
|
| 24 |
-
contents=
|
| 25 |
)
|
| 26 |
|
| 27 |
return response.text
|
|
@@ -29,7 +20,7 @@ User Question:
|
|
| 29 |
gr.ChatInterface(
|
| 30 |
fn=qa_ai_bot,
|
| 31 |
title="🤖 AI QA Automation Assistant",
|
| 32 |
-
description="Ask about Selenium, Cypress, API Testing, Bug Reports
|
| 33 |
examples=[
|
| 34 |
"Write Selenium POM login test",
|
| 35 |
"Generate Cypress test for signup page",
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
from google import genai
|
| 4 |
|
|
|
|
|
|
|
|
|
|
| 5 |
def qa_ai_bot(message, history):
|
| 6 |
+
api_key = os.getenv("AIzaSyCH9Pf6Bqe2nDGPKcwaqK91VbiD6_CoSqw")
|
|
|
|
| 7 |
|
| 8 |
+
if not api_key:
|
| 9 |
+
return "❌ GEMINI_API_KEY not set in Space variables."
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
client = genai.Client(api_key=api_key)
|
|
|
|
|
|
|
| 12 |
|
| 13 |
response = client.models.generate_content(
|
| 14 |
model="gemini-1.5-flash",
|
| 15 |
+
contents=f"You are a QA Automation expert.\n\n{message}"
|
| 16 |
)
|
| 17 |
|
| 18 |
return response.text
|
|
|
|
| 20 |
gr.ChatInterface(
|
| 21 |
fn=qa_ai_bot,
|
| 22 |
title="🤖 AI QA Automation Assistant",
|
| 23 |
+
description="Ask about Selenium, Cypress, API Testing, Bug Reports",
|
| 24 |
examples=[
|
| 25 |
"Write Selenium POM login test",
|
| 26 |
"Generate Cypress test for signup page",
|