Added support for palm
Browse files- app.py +14 -11
- docs/Rohan Marwaha.docx +0 -0
- models/hf_vs.index +0 -0
- models/hf_vs.pkl +3 -0
- models/openai_vs.pkl +0 -0
- models/palm_vs.index +0 -0
- models/palm_vs.pkl +3 -0
- requirements.txt +2 -1
- utils.py +6 -1
app.py
CHANGED
|
@@ -9,7 +9,7 @@ p = pipeline("automatic-speech-recognition")
|
|
| 9 |
|
| 10 |
"""Use text to call chat method from main.py"""
|
| 11 |
|
| 12 |
-
models = ["GPT-3.5", "Flan UL2", "Flan T5"]
|
| 13 |
|
| 14 |
name = os.environ.get("name", "Rohan")
|
| 15 |
|
|
@@ -76,19 +76,21 @@ def upload_file(files, history, model):
|
|
| 76 |
print("Ingesting files: " + str(file_paths))
|
| 77 |
text = 'Uploaded a file'
|
| 78 |
if ingest_files(file_paths, model):
|
| 79 |
-
response = 'Files are ingested'
|
| 80 |
else:
|
| 81 |
-
response = 'Files are not ingested'
|
| 82 |
|
| 83 |
history = history + [(text, response)]
|
| 84 |
return history
|
| 85 |
|
| 86 |
theme = gr.Theme.from_hub("snehilsanyal/scikit-learn")
|
| 87 |
|
| 88 |
-
theme.block_background_fill = gr.themes.colors.neutral.
|
|
|
|
|
|
|
| 89 |
|
| 90 |
|
| 91 |
-
with gr.Blocks(theme) as demo:
|
| 92 |
# Add image of Roar Logo from local directory
|
| 93 |
gr.HTML('<img src="file/assets/logo.png" style="width: 100px; height: 100px; margin: 0 auto;border:5px solid orange;border-radius: 50%; display: block">')
|
| 94 |
# Title on top in middle of the page
|
|
@@ -98,22 +100,23 @@ with gr.Blocks(theme) as demo:
|
|
| 98 |
|
| 99 |
with gr.Row():
|
| 100 |
# Create radio button to select model
|
| 101 |
-
radio = gr.Radio(models, label="Choose a model", value="GPT-3.5", type="value"
|
| 102 |
with gr.Row():
|
| 103 |
with gr.Column(scale=0.6):
|
| 104 |
txt = gr.Textbox(
|
| 105 |
-
label="
|
| 106 |
placeholder="Enter text and press enter, or upload a file", lines=1
|
| 107 |
).style(container=False)
|
| 108 |
|
| 109 |
with gr.Column(scale=0.2):
|
| 110 |
-
upload = gr.UploadButton(label="
|
| 111 |
|
| 112 |
with gr.Column(scale=0.2):
|
| 113 |
-
audio = gr.Audio(source="microphone", type="filepath").style(container=False)
|
| 114 |
|
| 115 |
with gr.Row():
|
| 116 |
-
gr.Examples(examples=['What are you an expert of?'
|
|
|
|
| 117 |
|
| 118 |
txt.submit(add_text, [chatbot, txt, radio], [chatbot, txt], postprocess=False).then(
|
| 119 |
bot, chatbot, chatbot
|
|
@@ -133,4 +136,4 @@ with gr.Blocks(theme) as demo:
|
|
| 133 |
if __name__ == "__main__":
|
| 134 |
demo.queue()
|
| 135 |
demo.queue(concurrency_count=5)
|
| 136 |
-
demo.launch(debug=True)
|
|
|
|
| 9 |
|
| 10 |
"""Use text to call chat method from main.py"""
|
| 11 |
|
| 12 |
+
models = ["GPT-3.5", "Flan UL2", "Flan T5", "Palm"]
|
| 13 |
|
| 14 |
name = os.environ.get("name", "Rohan")
|
| 15 |
|
|
|
|
| 76 |
print("Ingesting files: " + str(file_paths))
|
| 77 |
text = 'Uploaded a file'
|
| 78 |
if ingest_files(file_paths, model):
|
| 79 |
+
response = 'Files are ingested. Roar now!'
|
| 80 |
else:
|
| 81 |
+
response = 'Files are not ingested. Please try again.'
|
| 82 |
|
| 83 |
history = history + [(text, response)]
|
| 84 |
return history
|
| 85 |
|
| 86 |
theme = gr.Theme.from_hub("snehilsanyal/scikit-learn")
|
| 87 |
|
| 88 |
+
theme.block_background_fill = gr.themes.colors.neutral.c100
|
| 89 |
+
theme.block_border_width = '2px'
|
| 90 |
+
theme.block_border_radius = '10px'
|
| 91 |
|
| 92 |
|
| 93 |
+
with gr.Blocks(theme=theme, title='Roar!') as demo:
|
| 94 |
# Add image of Roar Logo from local directory
|
| 95 |
gr.HTML('<img src="file/assets/logo.png" style="width: 100px; height: 100px; margin: 0 auto;border:5px solid orange;border-radius: 50%; display: block">')
|
| 96 |
# Title on top in middle of the page
|
|
|
|
| 100 |
|
| 101 |
with gr.Row():
|
| 102 |
# Create radio button to select model
|
| 103 |
+
radio = gr.Radio(models, label="Choose a model", value="GPT-3.5", type="value")
|
| 104 |
with gr.Row():
|
| 105 |
with gr.Column(scale=0.6):
|
| 106 |
txt = gr.Textbox(
|
| 107 |
+
label="Let's hear the roar!",
|
| 108 |
placeholder="Enter text and press enter, or upload a file", lines=1
|
| 109 |
).style(container=False)
|
| 110 |
|
| 111 |
with gr.Column(scale=0.2):
|
| 112 |
+
upload = gr.UploadButton(label="Roar on a file", type="file", file_count='multiple', file_types=['docx', 'txt', 'pdf', 'html']).style(container=False)
|
| 113 |
|
| 114 |
with gr.Column(scale=0.2):
|
| 115 |
+
audio = gr.Audio(source="microphone", type="filepath", label="Let me hear your roar!").style(container=False)
|
| 116 |
|
| 117 |
with gr.Row():
|
| 118 |
+
gr.Examples(examples=['Roar it! What are you an expert of?', ' Roar it! What are you currently doing?',
|
| 119 |
+
'Roar it! What is your opinion on Large Language Models?'], inputs=[txt], label="Examples")
|
| 120 |
|
| 121 |
txt.submit(add_text, [chatbot, txt, radio], [chatbot, txt], postprocess=False).then(
|
| 122 |
bot, chatbot, chatbot
|
|
|
|
| 136 |
if __name__ == "__main__":
|
| 137 |
demo.queue()
|
| 138 |
demo.queue(concurrency_count=5)
|
| 139 |
+
demo.launch(debug=True, favicon_path="file/assets/logo.png")
|
docs/Rohan Marwaha.docx
ADDED
|
Binary file (32.1 kB). View file
|
|
|
models/hf_vs.index
ADDED
|
Binary file (43.1 kB). View file
|
|
|
models/hf_vs.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:625e8ad0ba047ca6c1433b0f262471d94cbe5969a3ac5663df1e3bf60e47d32c
|
| 3 |
+
size 49561
|
models/openai_vs.pkl
CHANGED
|
Binary files a/models/openai_vs.pkl and b/models/openai_vs.pkl differ
|
|
|
models/palm_vs.index
ADDED
|
Binary file (43.1 kB). View file
|
|
|
models/palm_vs.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2a4fcb8df6e6711a1850b701dbb82ec9395e9c0e9574a0b0cc6afb632bfd3390
|
| 3 |
+
size 49561
|
requirements.txt
CHANGED
|
@@ -8,4 +8,5 @@ gtts
|
|
| 8 |
torch
|
| 9 |
tiktoken
|
| 10 |
huggingface-hub
|
| 11 |
-
gradio
|
|
|
|
|
|
| 8 |
torch
|
| 9 |
tiktoken
|
| 10 |
huggingface-hub
|
| 11 |
+
gradio
|
| 12 |
+
google-generativeai
|
utils.py
CHANGED
|
@@ -18,6 +18,7 @@ from langchain.prompts.chat import (
|
|
| 18 |
from langchain.text_splitter import CharacterTextSplitter
|
| 19 |
from langchain.vectorstores.faiss import FAISS
|
| 20 |
from langchain.cache import InMemoryCache
|
|
|
|
| 21 |
import traceback
|
| 22 |
|
| 23 |
|
|
@@ -25,7 +26,7 @@ langchain.llm_cache = InMemoryCache()
|
|
| 25 |
|
| 26 |
global model_name
|
| 27 |
|
| 28 |
-
models = ["GPT-3.5", "Flan UL2", "GPT-4", "Flan T5"]
|
| 29 |
|
| 30 |
pickle_file = "_vs.pkl"
|
| 31 |
updated_pickle_file = "_vs_updated.pkl"
|
|
@@ -89,6 +90,8 @@ def set_model(model):
|
|
| 89 |
elif model == "Flan T5":
|
| 90 |
print("Loading Flan T5")
|
| 91 |
llm = HuggingFaceHub(repo_id="google/flan-t5-base", model_kwargs={"temperature": 0.1})
|
|
|
|
|
|
|
| 92 |
else:
|
| 93 |
print("Loading GPT-3.5 from else")
|
| 94 |
llm = OpenAI(model_name="text-davinci-002", temperature=0.1)
|
|
@@ -146,6 +149,8 @@ def get_file_path(model, file):
|
|
| 146 |
# If model is GPT3.5 or GPT4 return models_folder + openai + file else return models_folder + hf + file
|
| 147 |
if model == "GPT-3.5" or model == "GPT-4":
|
| 148 |
return models_folder + "openai" + file
|
|
|
|
|
|
|
| 149 |
else:
|
| 150 |
return models_folder + "hf" + file
|
| 151 |
|
|
|
|
| 18 |
from langchain.text_splitter import CharacterTextSplitter
|
| 19 |
from langchain.vectorstores.faiss import FAISS
|
| 20 |
from langchain.cache import InMemoryCache
|
| 21 |
+
from langchain.chat_models import ChatGooglePalm
|
| 22 |
import traceback
|
| 23 |
|
| 24 |
|
|
|
|
| 26 |
|
| 27 |
global model_name
|
| 28 |
|
| 29 |
+
models = ["GPT-3.5", "Flan UL2", "GPT-4", "Flan T5", "Palm"]
|
| 30 |
|
| 31 |
pickle_file = "_vs.pkl"
|
| 32 |
updated_pickle_file = "_vs_updated.pkl"
|
|
|
|
| 90 |
elif model == "Flan T5":
|
| 91 |
print("Loading Flan T5")
|
| 92 |
llm = HuggingFaceHub(repo_id="google/flan-t5-base", model_kwargs={"temperature": 0.1})
|
| 93 |
+
elif model == "Palm":
|
| 94 |
+
llm = ChatGooglePalm(temperature=0)
|
| 95 |
else:
|
| 96 |
print("Loading GPT-3.5 from else")
|
| 97 |
llm = OpenAI(model_name="text-davinci-002", temperature=0.1)
|
|
|
|
| 149 |
# If model is GPT3.5 or GPT4 return models_folder + openai + file else return models_folder + hf + file
|
| 150 |
if model == "GPT-3.5" or model == "GPT-4":
|
| 151 |
return models_folder + "openai" + file
|
| 152 |
+
elif model == "Palm":
|
| 153 |
+
return models_folder + "palm" + file
|
| 154 |
else:
|
| 155 |
return models_folder + "hf" + file
|
| 156 |
|