Spaces:
Sleeping
Sleeping
JayWadekar
commited on
Commit
·
9b1bd0f
1
Parent(s):
96d605c
gemini
Browse files
app.py
CHANGED
@@ -1,23 +1,25 @@
|
|
1 |
# AI assistant with a RAG system to query information from
|
2 |
-
# the gwIAS search
|
3 |
# using Langchain and deployed with Gradio
|
4 |
|
5 |
from rag import RAG, load_docs
|
|
|
6 |
from langchain_community.embeddings import HuggingFaceInstructEmbeddings
|
7 |
-
from
|
8 |
import gradio as gr
|
|
|
9 |
|
10 |
# Load the documentation
|
11 |
docs = load_docs()
|
12 |
print("Pages loaded:", len(docs))
|
13 |
|
14 |
# LLM model
|
15 |
-
llm = ChatOpenAI(model="gpt-
|
|
|
16 |
|
17 |
# Embeddings
|
18 |
embed_model = "sentence-transformers/multi-qa-distilbert-cos-v1"
|
19 |
# embed_model = "nvidia/NV-Embed-v2"
|
20 |
-
# text-embedding-3-small
|
21 |
embeddings = HuggingFaceInstructEmbeddings(model_name=embed_model)
|
22 |
|
23 |
# RAG chain
|
@@ -36,9 +38,10 @@ def handle_prompt(message, history):
|
|
36 |
|
37 |
|
38 |
if __name__ == "__main__":
|
|
|
39 |
# Predefined messages and examples
|
40 |
description = "AI powered assistant to help with [gwIAS](https://github.com/JayWadekar/gwIAS-HM) gravitational wave search pipeline."
|
41 |
-
|
42 |
example_questions = [
|
43 |
"Can you give me the code for calculating coherent score?",
|
44 |
"Which module in the code is used for collecting coincident triggers?",
|
@@ -46,23 +49,24 @@ if __name__ == "__main__":
|
|
46 |
]
|
47 |
|
48 |
# Define customized Gradio chatbot
|
49 |
-
chatbot = gr.Chatbot(
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
height="60vh"
|
54 |
-
)
|
55 |
|
56 |
# Define Gradio interface
|
57 |
-
demo = gr.ChatInterface(
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
|
67 |
-
# Launch the interface
|
68 |
demo.launch()
|
|
|
|
|
|
|
|
|
|
1 |
# AI assistant with a RAG system to query information from
|
2 |
+
# the gwIAS search pipline
|
3 |
# using Langchain and deployed with Gradio
|
4 |
|
5 |
from rag import RAG, load_docs
|
6 |
+
from langchain_google_genai import ChatGoogleGenerativeAI
|
7 |
from langchain_community.embeddings import HuggingFaceInstructEmbeddings
|
8 |
+
#from langchain.chat_models import ChatOpenAI
|
9 |
import gradio as gr
|
10 |
+
import os
|
11 |
|
12 |
# Load the documentation
|
13 |
docs = load_docs()
|
14 |
print("Pages loaded:", len(docs))
|
15 |
|
16 |
# LLM model
|
17 |
+
#llm = ChatOpenAI(model="gpt-4o-mini")
|
18 |
+
llm = ChatGoogleGenerativeAI(model="gemini-2.0-flash", temperature=0)
|
19 |
|
20 |
# Embeddings
|
21 |
embed_model = "sentence-transformers/multi-qa-distilbert-cos-v1"
|
22 |
# embed_model = "nvidia/NV-Embed-v2"
|
|
|
23 |
embeddings = HuggingFaceInstructEmbeddings(model_name=embed_model)
|
24 |
|
25 |
# RAG chain
|
|
|
38 |
|
39 |
|
40 |
if __name__ == "__main__":
|
41 |
+
|
42 |
# Predefined messages and examples
|
43 |
description = "AI powered assistant to help with [gwIAS](https://github.com/JayWadekar/gwIAS-HM) gravitational wave search pipeline."
|
44 |
+
greetingsmessage = "Hi, I'm the gwIAS Bot, I'm here to assist you with the search pipeline."
|
45 |
example_questions = [
|
46 |
"Can you give me the code for calculating coherent score?",
|
47 |
"Which module in the code is used for collecting coincident triggers?",
|
|
|
49 |
]
|
50 |
|
51 |
# Define customized Gradio chatbot
|
52 |
+
chatbot = gr.Chatbot([{"role": "assistant", "content": greetingsmessage}],
|
53 |
+
type="messages",
|
54 |
+
avatar_images=["ims/userpic.png", "ims/gwIASlogo.jpg"],
|
55 |
+
height="60vh")
|
|
|
|
|
56 |
|
57 |
# Define Gradio interface
|
58 |
+
demo = gr.ChatInterface(handle_prompt,
|
59 |
+
type="messages",
|
60 |
+
title="gwIAS DocBot",
|
61 |
+
fill_height=True,
|
62 |
+
examples=example_questions,
|
63 |
+
theme=gr.themes.Soft(),
|
64 |
+
description=description,
|
65 |
+
# cache_examples=False,
|
66 |
+
chatbot=chatbot)
|
67 |
|
|
|
68 |
demo.launch()
|
69 |
+
|
70 |
+
# https://arxiv.org/html/2405.17400v2
|
71 |
+
# https://arxiv.org/html/2312.06631v1
|
72 |
+
# https://arxiv.org/html/2310.15233v2
|