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 """KnowBot Server running with Salesforce Knowledge Article Data with Generative AI. Architect : Soumyabrata Das (https://www.linkedin.com/in/soumyabrata-das-b0567b17) """ 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)