Tog bort en onödig nästling av dictionary för "models"
This commit is contained in:
@@ -73,26 +73,27 @@ def configure():
|
||||
for endpoint in global_state.get_endpoints():
|
||||
if endpoint["provider"] == "ollama":
|
||||
if "requestOptions" in endpoint: # Check if authentication is needed
|
||||
# headers = {
|
||||
# "Content-Type": "application/json",
|
||||
# "Authorization": endpoint["requestOptions"]["headers"]["Authorization"]
|
||||
# }
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": endpoint["requestOptions"]["headers"]["Authorization"]
|
||||
}
|
||||
# headers = {
|
||||
# "Authorization": endpoint["requestOptions"]["headers"]["Authorization"]
|
||||
# }
|
||||
else: # otherwise proceed without authentication
|
||||
# headers = {"Content-Type": "application/json"}
|
||||
headers = None
|
||||
headers = {"Content-Type": "application/json"}
|
||||
# headers = None
|
||||
# models = tag(url = endpoint["url"], headers = headers) # Ask for models (LLMs) available at endpoint
|
||||
try:
|
||||
models = requests.get(endpoint["url"] + "/api/tags", headers=headers).json()
|
||||
# models = requests.get(endpoint["url"] + "/api/tags", headers=headers)
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"Error: {e}")
|
||||
|
||||
if isinstance(models, dict) and 'error' in models:
|
||||
logger.error('Error fetching models from backend: %s', models['error'])
|
||||
else:
|
||||
endpoint["models"] = models # Update endpoint with detected models
|
||||
endpoint["models"] = models.get("models", []) # get the list of models directly
|
||||
logger.debug("models = \n{}".format(json.dumps(models, indent=4)))
|
||||
if endpoint["model"] is not "AUTODETECT": # Check if specified model is available
|
||||
# do something
|
||||
|
||||
Reference in New Issue
Block a user