Skip to content

Commit a4da199

Browse files
committed
Adding Google File Search tool
1 parent 3ed8d4f commit a4da199

File tree

3 files changed

+47
-3
lines changed

3 files changed

+47
-3
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ user-friendly interface.
3737
- 🎛️ Customizable system prompts to tailor responses 🛠️
3838
- 🌐 Special command for quick and easy language translation tasks
3939
- 📁 Upload a variety of documents (text, PDF, images, video) to Google Gemini for analysis and processing
40+
- 🔎 [File Search](https://ai.google.dev/gemini-api/docs/file-search) The Gemini API enables Retrieval Augmented Generation ("RAG") through the File Search tool
4041
- 🧠 Awesome Prompts 150+ awesome prompts most of them from [Awesome ChatGPT Prompts](https://github.com/f/awesome-chatgpt-prompts) to select with one click.
4142

4243
###### \### Help the project by giving a star. \###
@@ -83,11 +84,19 @@ It will only work when the currently active model is any of Google Gemini.
8384
### Grounding with Google Search
8485
- `g: what's the main news today`
8586

86-
The Grounding with Google Search feature in the Gemini API can be used to improve the accuracy and recency of the model's
87+
The Grounding with `Google Search` feature in the Gemini API can be used to improve the accuracy and recency of the model's
8788
responses, essentially an internal RAG within the Gemini API itself.
8889

8990
You can now use this feature when using any Gemini 2.0 model, whether flash or pro, simply by typing `g: + your prompt.`
9091

92+
### File Search
93+
- `fs: What does my files say about philanthropy?`
94+
95+
File Search is a new feature of the Google Gemini API that allows you to index your own files and use them as context for Gemini.
96+
97+
Note: OrionChat does not provide an interface for creating a `FileSearchStore` and uploading files to it.
98+
You can do this via the Google API and then configure the name (ID) of your store in OrionChat.
99+
91100

92101
### Deep Thinking
93102
- ``dt: Explain quantum entanglement``

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<script src="js/storage_manager.js?v=1.0.1"></script>
7878
<script src="js/prompts.js?v=1.1.0"></script>
7979
<script src="js/tools_list.js?v=1.2.0"></script>
80-
<script src="js/script.js?v=3.3.0"></script>
80+
<script src="js/script.js?v=3.3.1"></script>
8181
<script src="js/search_chats.js?v=0.0.5"></script>
8282
<script src="js/voice_rec.js?v=1.0.6"></script>
8383
<div class="recording-animation">

js/script.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ let chosen_platform = localStorage.getItem('chosen_platform');
55
let model = localStorage.getItem('selected_model');
66
let is_mobile = window.matchMedia("(max-width: 768px)").matches;
77
let api_key = localStorage.getItem(`${chosen_platform}.api_key`)
8+
let file_search_store_id = localStorage.getItem("file_search_store_id");
89
let base64String = '';
910
let mimeType = '';
1011
let story = '';
@@ -1239,9 +1240,16 @@ function geminiChat(fileUri = '', with_stream = true, the_data = '') {
12391240
if (last_user_input.match(/^g:/i)) {
12401241
// Grounding with Google Search
12411242
data.tools = [{'google_search': {}}];
1242-
12431243
}
12441244

1245+
conversations.messages.forEach(cnv=>{
1246+
if(file_search_store_id){
1247+
data.tools = [{'file_search' : { file_search_store_names: file_search_store_id}}];
1248+
}else {
1249+
addWarning("File Search is not configured!", false)
1250+
}
1251+
})
1252+
12451253

12461254
}
12471255

@@ -1455,6 +1463,8 @@ function setOptions() {
14551463
let more_option = `<button class="more_opt_btn" onclick="moreOptions()">More Options</button>`;
14561464
let btn_youtube_api = `<button class="more_opt_btn" onclick="dialogSetYouTubeCaptionApiEndpoint()">YouTube Captions</button>`;
14571465

1466+
let file_search_tool = `<button class="more_opt_btn" onclick="dialogFileSearchTool()">File Search</button>`;
1467+
14581468
let cnt =
14591469
`<div>${platform_options}
14601470
<input type="text" name="api_key" placeholder="API Key(if not defined yet)">
@@ -1468,6 +1478,7 @@ function setOptions() {
14681478
<span>${add_new_models}</span>
14691479
<span>${plugin_option}</span>
14701480
<span>${more_option}</span>
1481+
<span>${file_search_tool}</span>
14711482
<span>${btn_youtube_api}</span>
14721483
14731484
</div>`;
@@ -1803,6 +1814,30 @@ function dialogSetYouTubeCaptionApiEndpoint() {
18031814
createDialog(cnt, 0, 'optionsDialog');
18041815
}
18051816

1817+
function dialogFileSearchTool(){
1818+
let input_value = '';
1819+
let cnt =
1820+
`<div><p>Gemini File Search</p>
1821+
<input ${input_value} id="file_search_tool" name="file_search_tool" placeholder="Store Name (ID)">
1822+
<button onclick="setFileSearchTool()">Save</button>
1823+
<p>The Gemini API enables Retrieval Augmented Generation ("RAG") through the <a href="https://ai.google.dev/gemini-api/docs/file-search">File Search</a> tool.</p>
1824+
<p>If you already have a store with indexed files, set your store ID above.
1825+
Whenever you want a response from Gemini based on indexed data, type "fs: + your prompt"</p>
1826+
</div>
1827+
<div></div>
1828+
`
1829+
createDialog(cnt, 0, 'optionsDialog');
1830+
}
1831+
1832+
function setFileSearchTool(){
1833+
let ele = document.querySelector("#file_search_tool");
1834+
if (ele) {
1835+
let file_search_tool = ele.value.trim();
1836+
localStorage.setItem('file_search_store_id', file_search_tool);
1837+
file_search_store_id = file_search_tool;
1838+
}
1839+
closeDialogs();
1840+
}
18061841

18071842
function orderTopics() {
18081843
let topics = document.querySelectorAll('.topic');

0 commit comments

Comments
 (0)