INNER CODE UNIT · Python

get_prompt

grumpyp/aixplora · backend/main.py:256

def get_prompt():
    db = Database().get_session()
    prompts = db.execute(text("SELECT * FROM prompt")).fetchall()
    prompts = sorted(prompts, key=lambda x: x[2], reverse=True)
    print(prompts)
    if len(prompts) == 0:
        return {
            "prompt": "Answer the following question: {question} based on that context:"
                      " {relevant_docs}, make sure that the answer of you is in the same language"
                      " then the question. if you can't just answer: I don't know."}
    return {"prompt": prompts[0][1]}


@app.post("/prompt/")
def add_prompt(prompt: Prompt):
    from database.models.prompt import Prompt
    db = Database().get_session()
    entry = Prompt(prompt=prompt.prompt)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…