You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here in the example, instead of defining this function:
importsubprocessimporttimeimportrequestsimportlogginglogging.basicConfig(level=logging.INFO)
defstart_ollama_server(timeout: int=30, check_interval: float=1.0):
""" Start the Ollama server and wait for it to be ready. """logging.info("Starting Ollama server...")
try:
process=subprocess.Popen(
['ollama', 'serve'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
exceptsubprocess.SubprocessErrorase:
logging.error(f"Failed to start Ollama process: {e}")
raisestart_time=time.time()
whiletime.time() -start_time<timeout:
try:
response=requests.get('http://localhost:11434', timeout=5)
ifresponse.status_code==200:
logging.info("Ollama server is ready.")
returnprocessexceptrequests.ConnectionError:
passexceptrequests.RequestExceptionase:
logging.error(f"Unexpected error when checking Ollama server: {e}")
process.terminate()
raiseifprocess.poll() isnotNone:
stdout, stderr=process.communicate()
logging.error(f"Ollama process terminated unexpectedly. stdout: {stdout}, stderr: {stderr}")
raisesubprocess.SubprocessError("Ollama process terminated unexpectedly")
time.sleep(check_interval)
process.terminate()
raiseTimeoutError(f"Ollama server did not start within {timeout} seconds")
Here in the example, instead of defining this function:
We should just use the Ollama Manager.
Plus, this should also be updated in other parts of the example and the github repo.
The text was updated successfully, but these errors were encountered: