Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import json, os
|
|
|
|
| 2 |
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
from fastapi import FastAPI, Request, Header, BackgroundTasks, HTTPException, status
|
| 4 |
import google.generativeai as genai
|
|
@@ -26,7 +27,23 @@ app.add_middleware(
|
|
| 26 |
|
| 27 |
@app.get("/")
|
| 28 |
def root():
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
@app.post("/webhook")
|
| 32 |
async def webhook(
|
|
|
|
| 1 |
import json, os
|
| 2 |
+
import gradio as gr
|
| 3 |
from fastapi.middleware.cors import CORSMiddleware
|
| 4 |
from fastapi import FastAPI, Request, Header, BackgroundTasks, HTTPException, status
|
| 5 |
import google.generativeai as genai
|
|
|
|
| 27 |
|
| 28 |
@app.get("/")
|
| 29 |
def root():
|
| 30 |
+
def get_gemini_response(input):
|
| 31 |
+
response = model.generate_content(input)
|
| 32 |
+
return response.text
|
| 33 |
+
# Define the Gradio interface
|
| 34 |
+
iface = gr.Interface(
|
| 35 |
+
fn=get_gemini_response,
|
| 36 |
+
inputs=[
|
| 37 |
+
gr.Textbox(label="Enter your question here:"),
|
| 38 |
+
],
|
| 39 |
+
outputs=gr.Textbox(label="The response is"),
|
| 40 |
+
title="Gemini Bot",
|
| 41 |
+
description="Ask Gemini!!!",
|
| 42 |
+
)
|
| 43 |
+
# Launch the Gradio interface
|
| 44 |
+
iface.launch()
|
| 45 |
+
|
| 46 |
+
return {"title": "Line Bot"}
|
| 47 |
|
| 48 |
@app.post("/webhook")
|
| 49 |
async def webhook(
|