EinsteinCoder commited on
Commit
86afeab
·
1 Parent(s): bb1efd4

added app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -0
app.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, HTTPException
2
+ from fastapi.middleware.cors import CORSMiddleware
3
+ import uvicorn
4
+ import nest_asyncio
5
+ from pydantic import BaseModel, Field
6
+ import json
7
+ import pandas as pd
8
+ from simple_salesforce import Salesforce
9
+ from langchain.chains.question_answering import load_qa_chain
10
+ from langchain.llms import OpenAI
11
+ from langchain.prompts import PromptTemplate
12
+ from langchain.memory import ConversationBufferMemory
13
+ from langchain.chat_models import ChatOpenAI
14
+ from langchain.chains import RetrievalQA
15
+ from langchain.embeddings.openai import OpenAIEmbeddings
16
+ from langchain.vectorstores import FAISS
17
+ from langchain.document_loaders import DataFrameLoader
18
+ import os
19
+
20
+
21
+ app = FastAPI()
22
+
23
+ origins = ["*"]
24
+
25
+ app.add_middleware(
26
+ CORSMiddleware,
27
+ allow_origins=origins,
28
+ allow_credentials=True,
29
+ allow_methods=["*"],
30
+ allow_headers=["*"],
31
+ )
32
+
33
+ @app.get('/')
34
+ def index():
35
+ return """KnowBot Server running with Salesforce Knowledge Article Data with Generative AI.
36
+ Architect : Soumyabrata Das (https://www.linkedin.com/in/soumyabrata-das-b0567b17)
37
+ """
38
+
39
+ if __name__ == '__main__':
40
+ #nest_asyncio.apply()
41
+ #uvicorn.run("app:app",host='localhost', port=5000, reload=True)
42
+ uvicorn.run(app,host='0.0.0.0', port=5000)