fastapi-demo / app.py
EinsteinCoder's picture
Update app.py
312e49d
raw
history blame
1.2 kB
from fastapi import FastAPI, HTTPException
from fastapi.middleware.cors import CORSMiddleware
import uvicorn
#import nest_asyncio
from pydantic import BaseModel, Field
import json
import pandas as pd
from simple_salesforce import Salesforce
from langchain.chains.question_answering import load_qa_chain
from langchain.llms import OpenAI
from langchain.prompts import PromptTemplate
from langchain.memory import ConversationBufferMemory
from langchain.chat_models import ChatOpenAI
from langchain.chains import RetrievalQA
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.vectorstores import FAISS
from langchain.document_loaders import DataFrameLoader
import os
app = FastAPI()
origins = ["*"]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get('/')
def index():
return """FastAPI Server Running on HuggingFace Spaces. Docs available at: https://einsteincoder-fastapi-demo.hf.space/docs"""
#if __name__ == '__main__':
#nest_asyncio.apply()
#uvicorn.run("app:app",host='localhost', port=5000, reload=True)
#uvicorn.run(app,host='0.0.0.0', port=5000)