This pull request includes several improvements to the get_remote_llms method in the src/hugchat/hugchat.py file. The changes aim to enhance error handling and data processing when fetching remote LLMs.
Error handling improvements:
Added a try block to handle potential errors when processing each line of the response text as JSON.
Included an except block to catch and log json.JSONDecodeError for malformed lines, ensuring the method continues processing valid lines.
Added a general except block to catch and log any other exceptions that may occur during parsing.
Data processing enhancements:
Introduced a loop to split the response text by lines and process each line individually as JSON.
Simplified the logic for handling promptExamples and parameters by ensuring proper indentation and removing commented-out code.
See #267
This pull request includes several improvements to the
get_remote_llms
method in thesrc/hugchat/hugchat.py
file. The changes aim to enhance error handling and data processing when fetching remote LLMs.Error handling improvements:
try
block to handle potential errors when processing each line of the response text as JSON.except
block to catch and logjson.JSONDecodeError
for malformed lines, ensuring the method continues processing valid lines.except
block to catch and log any other exceptions that may occur during parsing.Data processing enhancements:
promptExamples
andparameters
by ensuring proper indentation and removing commented-out code.