repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | import os |
| #2 | |
| #3 | from flask import Blueprint, jsonify, make_response, request |
| #4 | from models import APIKey |
| #5 | from paths import DB_DIRECTORY_OPEN_AI |
| #6 | |
| #7 | from embedchain import App |
| #8 | |
| #9 | sources_bp = Blueprint("sources", __name__) |
| #10 | |
| #11 | |
| #12 | # API route to add data sources |
| #13 | @sources_bp.route("/api/add_sources", methods=["POST"]) |
| #14 | def add_sources(): |
| #15 | try: |
| #16 | embedding_model = request.json.get("embedding_model") |
| #17 | name = request.json.get("name") |
| #18 | value = request.json.get("value") |
| #19 | if embedding_model == "open_ai": |
| #20 | os.chdir(DB_DIRECTORY_OPEN_AI) |
| #21 | api_key = APIKey.query.first().key |
| #22 | os.environ["OPENAI_API_KEY"] = api_key |
| #23 | chat_bot = App() |
| #24 | chat_bot.add(name, value) |
| #25 | return make_response(jsonify(message="Sources added successfully"), 200) |
| #26 | except Exception as e: |
| #27 | return make_response(jsonify(message=f"Error adding sources: {str(e)}"), 400) |
| #28 |