Update.
This commit is contained in:
		
							parent
							
								
									1882ed4eb3
								
							
						
					
					
						commit
						8e7e5f96c3
					
				
							
								
								
									
										17
									
								
								auth.h
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								auth.h
									
									
									
									
									
								
							| @ -19,10 +19,27 @@ enum AUTH_TYPE { | |||||||
| 
 | 
 | ||||||
| int auth_type = AUTH_TYPE_FREE; | int auth_type = AUTH_TYPE_FREE; | ||||||
| 
 | 
 | ||||||
|  | void auth_init() { | ||||||
|  |     char *api_key = NULL; | ||||||
|  |     api_key = getenv("R_KEY"); | ||||||
|  |     if (api_key) { | ||||||
|  |         auth_type = AUTH_TYPE_API_KEY; | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  |     api_key = getenv("OPENAI_API_KEY"); | ||||||
|  |     if (api_key) { | ||||||
|  |         auth_type = AUTH_TYPE_API_KEY; | ||||||
|  |         return; | ||||||
|  |     }  | ||||||
|  |     auth_type = AUTH_TYPE_FREE; | ||||||
|  |     return; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| const char *resolve_api_key() { | const char *resolve_api_key() { | ||||||
|     static char *api_key = NULL; |     static char *api_key = NULL; | ||||||
|     api_key = getenv("R_KEY"); |     api_key = getenv("R_KEY"); | ||||||
|     if (api_key) { |     if (api_key) { | ||||||
|  |         auth_type = AUTH_TYPE_API_KEY; | ||||||
|         return api_key; |         return api_key; | ||||||
|     } |     } | ||||||
|     api_key = getenv("OPENAI_API_KEY"); |     api_key = getenv("OPENAI_API_KEY"); | ||||||
|  | |||||||
							
								
								
									
										9
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								main.c
									
									
									
									
									
								
							| @ -289,6 +289,7 @@ bool openai_include(char *path) { | |||||||
| void init() { | void init() { | ||||||
|     setbuf(stdout, NULL); |     setbuf(stdout, NULL); | ||||||
|     line_init(); |     line_init(); | ||||||
|  |     auth_init(); | ||||||
|     const char *locale = setlocale(LC_ALL, NULL); |     const char *locale = setlocale(LC_ALL, NULL); | ||||||
|     char payload[4096] = {0}; |     char payload[4096] = {0}; | ||||||
|     sprintf(payload, "Your locale is %s. User lang is %s.", locale, locale); |     sprintf(payload, "Your locale is %s. User lang is %s.", locale, locale); | ||||||
| @ -296,12 +297,8 @@ void init() { | |||||||
|     openai_system(payload); |     openai_system(payload); | ||||||
|     if(!openai_include(".rcontext.txt")){ |     if(!openai_include(".rcontext.txt")){ | ||||||
|         openai_include("~/.rcontext.txt"); |         openai_include("~/.rcontext.txt"); | ||||||
|     } |     }  | ||||||
|     #ifndef FREE_VERSION |     fprintf(stderr, "\r                          \r"); | ||||||
|     fprintf(stderr, "%s", "\r✅ Commercial version. Type help for features.\n"); |  | ||||||
|     #else |  | ||||||
|     fprintf(stderr, "%s","\r✅ Free version (GPT-3.5 Turbo), for you by retoor.\n"); |  | ||||||
|     #endif |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int main(int argc, char *argv[]) { | int main(int argc, char *argv[]) { | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user