mirror of
				https://github.com/SillyTavern/SillyTavern.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	Include additional headers for all supported Text Completion types.
This commit is contained in:
		| @@ -35,11 +35,15 @@ skipContentCheck: false | |||||||
| # Disable automatic chats backup | # Disable automatic chats backup | ||||||
| disableChatBackup: false | disableChatBackup: false | ||||||
| # API request overrides (for KoboldAI and Text Completion APIs) | # API request overrides (for KoboldAI and Text Completion APIs) | ||||||
|  | ## Note: host includes the port number if it's not the default (80 or 443) | ||||||
| ## Format is an array of objects: | ## Format is an array of objects: | ||||||
| ## - hosts: | ## - hosts: | ||||||
| ##   - example.com | ##   - example.com | ||||||
| ##   headers: | ##   headers: | ||||||
| ##     Content-Type: application/json | ##     Content-Type: application/json | ||||||
|  | ##   - 127.0.0.1:5001 | ||||||
|  | ##   headers: | ||||||
|  | ##     User-Agent: "Googlebot/2.1 (+http://www.google.com/bot.html)" | ||||||
| requestOverrides: [] | requestOverrides: [] | ||||||
| # -- PLUGIN CONFIGURATION -- | # -- PLUGIN CONFIGURATION -- | ||||||
| # Enable UI extensions | # Enable UI extensions | ||||||
|   | |||||||
| @@ -124,10 +124,23 @@ function setAdditionalHeaders(request, args, server) { | |||||||
|             headers = getKoboldCppHeaders(); |             headers = getKoboldCppHeaders(); | ||||||
|             break; |             break; | ||||||
|         default: |         default: | ||||||
|             headers = server ? getOverrideHeaders((new URL(server))?.host) : {}; |             headers = {}; | ||||||
|             break; |             break; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     if (typeof server === 'string' && server.length > 0) { | ||||||
|  |         try { | ||||||
|  |             const url = new URL(server); | ||||||
|  |             const overrideHeaders =  getOverrideHeaders(url.host); | ||||||
|  |  | ||||||
|  |             if (overrideHeaders && Object.keys(overrideHeaders).length > 0) { | ||||||
|  |                 Object.assign(headers, overrideHeaders); | ||||||
|  |             } | ||||||
|  |         } catch { | ||||||
|  |             // Do nothing | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     Object.assign(args.headers, headers); |     Object.assign(args.headers, headers); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -607,7 +607,7 @@ router.post('/remote/textgenerationwebui/encode', jsonParser, async function (re | |||||||
|             headers: { 'Content-Type': 'application/json' }, |             headers: { 'Content-Type': 'application/json' }, | ||||||
|         }; |         }; | ||||||
|  |  | ||||||
|         setAdditionalHeaders(request, args, null); |         setAdditionalHeaders(request, args, baseUrl); | ||||||
|  |  | ||||||
|         // Convert to string + remove trailing slash + /v1 suffix |         // Convert to string + remove trailing slash + /v1 suffix | ||||||
|         let url = String(baseUrl).replace(/\/$/, '').replace(/\/v1$/, ''); |         let url = String(baseUrl).replace(/\/$/, '').replace(/\/v1$/, ''); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user