Update app.py
Browse files
app.py
CHANGED
|
@@ -2,8 +2,6 @@ import os
|
|
| 2 |
import google.generativeai as genai
|
| 3 |
from flask import Flask, request, jsonify
|
| 4 |
from flask_cors import CORS
|
| 5 |
-
from google.generativeai.types import Tool
|
| 6 |
-
from google.generativeai import protos
|
| 7 |
|
| 8 |
app = Flask(__name__)
|
| 9 |
CORS(app)
|
|
@@ -14,21 +12,7 @@ if not GOOGLE_API_KEY:
|
|
| 14 |
raise ValueError("GOOGLE_API_KEY nicht gesetzt!")
|
| 15 |
|
| 16 |
genai.configure(api_key=GOOGLE_API_KEY)
|
| 17 |
-
|
| 18 |
-
# Google Search Integration (korrigierte Syntax)
|
| 19 |
-
search_tool = protos.Tool(
|
| 20 |
-
google_search_retrieval=protos.GoogleSearchRetrieval(
|
| 21 |
-
disable_attribution=False,
|
| 22 |
-
max_return_results=3
|
| 23 |
-
)
|
| 24 |
-
)
|
| 25 |
-
|
| 26 |
-
model = genai.GenerativeModel(
|
| 27 |
-
'gemini-1.5-pro',
|
| 28 |
-
tools=[search_tool],
|
| 29 |
-
system_instruction="Du bist Moejra, KI-Lernbegleitung von learn.create.repeat. Nutze Web-Recherche bei Unsicherheiten."
|
| 30 |
-
)
|
| 31 |
-
|
| 32 |
chat = model.start_chat(history=[])
|
| 33 |
|
| 34 |
# --- API-Endpunkt ---
|
|
@@ -39,7 +23,7 @@ def handle_chat():
|
|
| 39 |
response = chat.send_message(user_input)
|
| 40 |
return jsonify({
|
| 41 |
"text": response.text,
|
| 42 |
-
"images": [
|
| 43 |
})
|
| 44 |
except Exception as e:
|
| 45 |
return jsonify({"error": str(e)}), 500
|
|
|
|
| 2 |
import google.generativeai as genai
|
| 3 |
from flask import Flask, request, jsonify
|
| 4 |
from flask_cors import CORS
|
|
|
|
|
|
|
| 5 |
|
| 6 |
app = Flask(__name__)
|
| 7 |
CORS(app)
|
|
|
|
| 12 |
raise ValueError("GOOGLE_API_KEY nicht gesetzt!")
|
| 13 |
|
| 14 |
genai.configure(api_key=GOOGLE_API_KEY)
|
| 15 |
+
model = genai.GenerativeModel('gemini-1.5-pro')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
chat = model.start_chat(history=[])
|
| 17 |
|
| 18 |
# --- API-Endpunkt ---
|
|
|
|
| 23 |
response = chat.send_message(user_input)
|
| 24 |
return jsonify({
|
| 25 |
"text": response.text,
|
| 26 |
+
"images": []
|
| 27 |
})
|
| 28 |
except Exception as e:
|
| 29 |
return jsonify({"error": str(e)}), 500
|