Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -9,6 +9,18 @@ from langchain_community.embeddings import HuggingFaceEmbeddings
|
|
9 |
from langchain_community.vectorstores import FAISS
|
10 |
from langchain.chains import ConversationalRetrievalChain
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
DB_FAISS_PATH = 'vectorstore/db_faiss'
|
13 |
|
14 |
app = FastAPI()
|
@@ -44,7 +56,15 @@ async def PromptLLM(file: UploadFile = File(...)):
|
|
44 |
chain = ConversationalRetrievalChain.from_llm(llm=llm, retriever=db.as_retriever())
|
45 |
|
46 |
result = chain({"question": "Summarise this report", "chat_history": ''})
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
|
50 |
|
|
|
9 |
from langchain_community.vectorstores import FAISS
|
10 |
from langchain.chains import ConversationalRetrievalChain
|
11 |
|
12 |
+
import google.generativeai as genai
|
13 |
+
|
14 |
+
|
15 |
+
GOOGLE_API_KEY = 'AIzaSyA13K0uJP5ti0R6eCy_ogK0UlqenbFfr_o'
|
16 |
+
|
17 |
+
genai.configure(api_key=GOOGLE_API_KEY)
|
18 |
+
|
19 |
+
|
20 |
+
model = genai.GenerativeModel('gemini-pro')
|
21 |
+
#response = model.generate_content(query)
|
22 |
+
#return response.text
|
23 |
+
|
24 |
DB_FAISS_PATH = 'vectorstore/db_faiss'
|
25 |
|
26 |
app = FastAPI()
|
|
|
56 |
chain = ConversationalRetrievalChain.from_llm(llm=llm, retriever=db.as_retriever())
|
57 |
|
58 |
result = chain({"question": "Summarise this report", "chat_history": ''})
|
59 |
+
summary = result['answer']
|
60 |
+
|
61 |
+
response = model.generate_content(summary + "\nBased on the information provided, what are the key medical insights and considerations for this patient?")
|
62 |
+
|
63 |
+
ans = {"summary": summary, "insights": response.text}
|
64 |
+
|
65 |
+
return ans
|
66 |
+
|
67 |
+
|
68 |
|
69 |
|
70 |
|