alanchen1115 commited on
Commit
0c5210d
·
verified ·
1 Parent(s): 98dc21e

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +0 -68
main.py CHANGED
@@ -8,74 +8,6 @@ from linebot import LineBotApi, WebhookHandler
8
  from linebot.exceptions import InvalidSignatureError
9
  from linebot.models import MessageEvent, TextMessage, TextSendMessage, ImageSendMessage, AudioMessage
10
 
11
- # genai.configure(api_key=os.environ["GOOGLE_API_KEY"])
12
- # generation_config = genai.types.GenerationConfig(max_output_tokens=2048, temperature=0.2, top_p=0.5, top_k=16)
13
- # model = genai.GenerativeModel('gemini-1.5-flash')
14
-
15
- # line_bot_api = LineBotApi(os.environ["CHANNEL_ACCESS_TOKEN"])
16
- # line_handler = WebhookHandler(os.environ["CHANNEL_SECRET"])
17
- # working_status = os.getenv("DEFALUT_TALKING", default = "true").lower() == "true"
18
-
19
- # app = FastAPI()
20
- # app.add_middleware(
21
- # CORSMiddleware,
22
- # allow_origins=["*"],
23
- # allow_credentials=True,
24
- # allow_methods=["*"],
25
- # allow_headers=["*"],
26
- # )
27
-
28
- # @app.get("/")
29
- # def root():
30
- # return {"title": "Line Bot"}
31
-
32
- # @app.post("/webhook")
33
- # async def webhook(
34
- # request: Request,
35
- # background_tasks: BackgroundTasks,
36
- # x_line_signature=Header(None),
37
- # ):
38
- # body = await request.body()
39
- # try:
40
- # background_tasks.add_task(
41
- # line_handler.handle, body.decode("utf-8"), x_line_signature
42
- # )
43
- # except InvalidSignatureError:
44
- # raise HTTPException(status_code=400, detail="Invalid signature")
45
- # return "ok"
46
-
47
- # @line_handler.add(MessageEvent, message=TextMessage)
48
- # def handle_message(event):
49
- # global working_status
50
-
51
- # if event.type != "message" or event.message.type != "text":
52
- # TextSendMessage(text="Event type error:[No message or the message does not contain text]")
53
-
54
- # elif event.message.text == "再見":
55
- # working_status = True
56
- # line_bot_api.reply_message(
57
- # event.reply_token,
58
- # TextSendMessage(text="Bye!"))
59
- # return
60
-
61
- # elif working_status:
62
- # try:
63
- # prompt = event.message.text
64
- # completion = model.generate_content(prompt, generation_config=generation_config)
65
- # if (completion.parts[0].text != None):
66
- # out = completion.parts[0].text
67
- # else:
68
- # out = "Gemini沒答案!請換個說法!"
69
- # except:
70
- # out = "Gemini執行出錯!請換個說法!"
71
-
72
- # line_bot_api.reply_message(
73
- # event.reply_token,
74
- # TextSendMessage(text=out))
75
-
76
- # if __name__ == "__main__":
77
- # uvicorn.run("main:app", host="0.0.0.0", port=7860, reload=True)
78
-
79
  # 設定 Google AI API 金鑰
80
  genai.configure(api_key=os.environ["GOOGLE_API_KEY"])
81
 
 
8
  from linebot.exceptions import InvalidSignatureError
9
  from linebot.models import MessageEvent, TextMessage, TextSendMessage, ImageSendMessage, AudioMessage
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  # 設定 Google AI API 金鑰
12
  genai.configure(api_key=os.environ["GOOGLE_API_KEY"])
13