Skip to content

Commit

Permalink
feat: Convert Langchain Chatbot to FastAPI applica
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] committed Dec 19, 2023
1 parent 5f913d0 commit b7ea58b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import json

from fastapi import FastAPI
from utils.llm_query import llm_query

app = FastAPI()

@app.post("/ingest")
def ingest_data():
from deprecated.chatbot import ingest
ingest_response = ingest()
return {"ingest_response": ingest_response}

@app.get("/query/{question}")
def query_data(question: str):
from deprecated.chatbot import query
result = query({"question": question, "chat_history": []})
return {"answer": result["answer"]}

@app.get("/chat_history")
def get_chat_history():
with open('chat_history.json', 'r') as json_file:
chat_history = json.load(json_file)
return {"chat_history": chat_history}

0 comments on commit b7ea58b

Please sign in to comment.