-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Convert Langchain Chatbot to FastAPI applica
- Loading branch information
1 parent
5f913d0
commit b7ea58b
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |