Spaces:
Sleeping
Sleeping
yellowflash.ai
Browse filesit is the main ai file
- yellowflash.ai +18 -0
yellowflash.ai
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr, requests
|
| 2 |
+
|
| 3 |
+
API_KEY="AIzaSyAPfDiu2V_aD6un00qHt5bkISm6C0Pkx7o"
|
| 4 |
+
API_URL="https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent"
|
| 5 |
+
|
| 6 |
+
def chat_fn(message, history):
|
| 7 |
+
try:
|
| 8 |
+
resp=requests.post(API_URL,headers={"Content-Type":"application/json",
|
| 9 |
+
"x-goog-api-key":API_KEY},
|
| 10 |
+
json={"contents":[{"parts":[{"text":message}]}]},timeout=12)
|
| 11 |
+
ans=resp.json()["candidates"][0]["content"]["parts"][0]["text"]
|
| 12 |
+
except Exception as e:
|
| 13 |
+
ans=f"Error: {e}"
|
| 14 |
+
return ans
|
| 15 |
+
|
| 16 |
+
demo = gr.ChatInterface(chat_fn, title="⚡ yellowflash.ai")
|
| 17 |
+
demo.launch(share=True)
|
| 18 |
+
|