add API version flag
I'm not sure what exactly is the name of that thing (the one with v1beta).
This commit is contained in:
		
							parent
							
								
									9f5dc33ce8
								
							
						
					
					
						commit
						33f13a237a
					
				
					 1 changed files with 5 additions and 5 deletions
				
			
		|  | @ -2,7 +2,8 @@ | ||||||
| // Import the file module.
 | // Import the file module.
 | ||||||
| // import file from `./net.js`;
 | // import file from `./net.js`;
 | ||||||
| 
 | 
 | ||||||
| class gemini { | // Don't forget to set the class as export default.
 | ||||||
|  | export default class gemini { | ||||||
|     #key; |     #key; | ||||||
|     #request; |     #request; | ||||||
| 
 | 
 | ||||||
|  | @ -10,8 +11,9 @@ class gemini { | ||||||
| 
 | 
 | ||||||
|     @param {string} key the API key. Remember to not commit your API keys. |     @param {string} key the API key. Remember to not commit your API keys. | ||||||
|     @param {string} model the model to use |     @param {string} model the model to use | ||||||
|  |     @param {object} version the API and bot version | ||||||
|     */ |     */ | ||||||
|     constructor (key, model) { |     constructor (key, model, version = {"API": "v1beta"}) { | ||||||
|         if ((key) ? (((typeof key).includes(`str`)) ? !(key.trim()) : true) : true) { |         if ((key) ? (((typeof key).includes(`str`)) ? !(key.trim()) : true) : true) { | ||||||
|             throw new Error(`The API key is required.`); |             throw new Error(`The API key is required.`); | ||||||
|         }; |         }; | ||||||
|  | @ -31,7 +33,7 @@ class gemini { | ||||||
|         this.model[`name`] = ((typeof model).includes(`str`) && model) ? ((model.includes(`models/`)) ? model : `models/`.concat(model)) : 'gemini-pro'; |         this.model[`name`] = ((typeof model).includes(`str`) && model) ? ((model.includes(`models/`)) ? model : `models/`.concat(model)) : 'gemini-pro'; | ||||||
| 
 | 
 | ||||||
|         // Set the request location.
 |         // Set the request location.
 | ||||||
|         this.#request[`location`] = `https://generativelanguage.googleapis.com/v1beta/`.concat(this.model.name); |         this.#request[`location`] = `https://generativelanguage.googleapis.com/`.concat(((version != null && !Array.isArray(version) && typeof(version).includes(`obj`)) ? version[`API`] : false) ? version[`API`] : `v1beta`, `/`, this.model.name); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | @ -178,5 +180,3 @@ class gemini { | ||||||
|         return(analyze(RESPONSE_RAW)); |         return(analyze(RESPONSE_RAW)); | ||||||
|     } |     } | ||||||
| }; | }; | ||||||
| 
 |  | ||||||
| module.exports = gemini; |  | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue